0

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You might want to look at stackoverflow.com/questions/9994295/… for more information on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.