Reputation: 36630
I have a wrapper script command.sh as main launch script for my python application, primarily to set some environment variables like PYTHONPATH
:
#!/bin/bash
export PYTHONPATH=lib64/python/side-packages
./command.py $*
command.py looks like this:
#!/usr/bin/python
import sys
print sys.argv
Calling the wrapper script like
$ ./command.sh a "b c"
results in ['./command.py', 'a', 'b', 'c']
, where I need ['./command.py', 'a', 'b c']
How can I pass parameters which contain spaces to the python script?
Upvotes: 0
Views: 3517
Reputation: 36630
Use $@
instead of $*
, and quote it with "
:
#!/bin/bash
export PYTHONPATH=lib64/python/side-packages
./command.py "$@"
See bash(1), section "Special Parameters", for more information.
Upvotes: 4