Unknown error when executing shell script

278 views Asked by At

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?

3

There are 3 answers

1
Ignacio Vazquez-Abrams On

Your script has the wrong line endings. Pass it through dos2unix.

0
Wes Hardaker On

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.

0
ghostdog74 On

Try using

bash -x cron.sh  

or

./cron.sh

make sure to make it executable.