0

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?

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
rmaceissoft
  • 512
  • 5
  • 16

3 Answers3

0

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • I'll be grateful forever Ignacio I was using eclipse at windows for edit remote files, and forget to set the delimiter line to unix. in two days is my birthday and I'll put a candle ;-) – rmaceissoft May 03 '11 at 01:56
0

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.

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69
0

Try using

bash -x cron.sh  

or

./cron.sh

make sure to make it executable.

ghostdog74
  • 327,991
  • 56
  • 259
  • 343