Unknown error when executing shell script
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/d开发者_StackOverflow社区omains/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?
Your script has the wrong line endings. Pass it through dos2unix
.
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 the python
invocation. If the errors are before that point, you know it's in the sh
half and what caused them. If after that, you'll have to debug the python
script.
Try using
bash -x cron.sh
or
./cron.sh
make sure to make it executable.
精彩评论