【发布时间】:2014-05-05 00:49:06
【问题描述】:
我想要一个脚本,它会激活一个虚拟环境(在 shell 和通过 cron 中),然后使用该 virtualenv 中的所有参数运行传递的脚本。
这是我现在为 prod.sh 准备的内容:
#!/bin/bash
. $VE_DIR/Production_VE/bin/activate
python $0 "$@"
然后我试试这个:
hostname:~$prod.sh myscript.py -c arg1 -fu
我收到此错误:
File "/home/username/prod.sh", line 3
. $VE_DIR/Production_VE/bin/activate
^
SyntaxError: invalid syntax
我尝试切换到源:
#!/bin/bash
source $VE_DIR/Production_VE/bin/activate
python $0 "$@"
错误发生了变化,但是现在:
File "/home/username/prod.sh", line 3
source $VE_DIR/Production_VE/bin/activate
^
SyntaxError: invalid syntax
对于其他上下文,我希望能够在 CentOS 6.5 VPS 和 Mac OS 上运行此脚本。
这张图怎么了?
谢谢!
【问题讨论】:
标签: python shell cron virtualenv