2013-03-27 161 views
0

我有一个包装脚本command.sh作为主要的启动脚本为我的Python应用程序,主要是设置一些环境变量,如PYTHONPATH参数传递

#!/bin/bash 

export PYTHONPATH=lib64/python/side-packages 
./command.py $* 

command.py看起来是这样的:

#!/usr/bin/python 

import sys 
print sys.argv 

调用包装脚本像

$ ./command.sh a "b c" 

结果['./command.py', 'a', 'b', 'c'],我需要['./command.py', 'a', 'b c']

如何传递包含空格的python脚本参数?

回答

3

使用[email protected]而不是$*,并与"帖吧:

#!/bin/bash 

export PYTHONPATH=lib64/python/side-packages 
./command.py "[email protected]" 

bash(1),部分 “特殊参数”,了解更多信息。

+1

你可能想看看http://stackoverflow.com/questions/9994295/what-does-mean-in-a-shell-script/9995322#9995322了解更多信息。 – Alfe 2013-03-27 14:43:40