vendredi 16 juillet 2021

Unable to run command based on whether item is in a list. Python

I'm setting up a home arcade machine and want to run a command depending on which system is started. It is using Python. I've tried creating a list and if the system used is in the list it runs a command, and a different command if it's in a different list. I cannot get it to work, no matter what I try.

For example, is I run a sega32x game, I get an error saying "sega32x: command not found". It isn't a command....

The command is the line starting "rotator...." This command works in terminal.

The whole "system=$1" works in the rest of the code, which I've omitted here.

Here is the relevant code:

#!/usr/bin/env bash

# Get system name
system=$1

if "$1" in ["atari2600", "atari7800", "atarilynx", "megadrive", "neogeo", "nes", "pcengine", "sega32x", "segacd", "snes"]
then
rotator 1 1 8 2 1 8
fi

if "$1" in ["dreamcast", "n64", "psx", "saturn"]
then
rotator 1 1 analog 2 1 analog
fi

I'm no good at this programming lark, so any help greatly appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire