执行 shell 脚本时出现未知错误
我在 cron.sh 文件中有以下 shell 脚本(bash 脚本)
#!/bin/bash
WORKON_HOME="/home/django/domains/example.com"
PROJECT_ROOT="/home/django/domains/example.com/django-project/"
. $WORKON_HOME/bin/activate
cd $PROJECT_ROOT
python manage.py cron
但是当我运行时:
$ sh cron.sh
我收到以下错误
: not found
: not found
/bin/activatepen /home/django/domains/example.com
服务器信息
cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
我做错了什么?
I have the following shell script (bash script) at cron.sh file
#!/bin/bash
WORKON_HOME="/home/django/domains/example.com"
PROJECT_ROOT="/home/django/domains/example.com/django-project/"
. $WORKON_HOME/bin/activate
cd $PROJECT_ROOT
python manage.py cron
But when i run:
$ sh cron.sh
I got the following error
: not found
: not found
/bin/activatepen /home/django/domains/example.com
Server info
cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的脚本的行结尾错误。通过
dos2unix
传递它。Your script has the wrong line endings. Pass it through
dos2unix
.好吧,您没有向我们展示您尝试运行的代码中的所有内容。因此,我将笼统地回答:
使用
sh -x cron.sh
运行脚本,这将为您提供非常详细的输出,说明在调用python
之前它正在执行的操作。如果错误发生在该点之前,您就知道错误发生在sh
部分以及导致错误的原因。如果之后,您将必须调试python
脚本。Well, you didn't show us everything in the code that you're trying to run. So I'll answer generically instead:
Run the script using
sh -x cron.sh
which will give you very verbose output of what it's doing up until thepython
invocation. If the errors are before that point, you know it's in thesh
half and what caused them. If after that, you'll have to debug thepython
script.尝试使用
或
确保使其可执行。
Try using
or
make sure to make it executable.