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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -