bash - Escape sequence not working in python script run from a shell script -
i have shell script needs run python script. python script may passed argument.
python pgm32.py $args but when argument passed has escape sequence or if encase in quotes, python scripts not recognize it.
for instance args contains "open drive" or open\ drive python script's sys.argv=['pgm32.py', '"open', 'drive"'] or sys.argv=['pgm32.py', '"open', 'drive"'] respectively.
but when call python script directly command line, , pass argument "open drive" or open\ drive, script's sys.arv=['pgm32.py', 'open drive']
how can fix issue?
it's quite simple. quote argument in shell command:
$ python pgm32.py "$args" you did yourself:
but when call python script directly command line, , pass argument "open drive" or open\ drive, script's sys.arv=['pgm32.py', 'open drive']
which worked because in these lines protected space shell word splitting; in other examples didn't. shell , has nothing python.
Comments
Post a Comment