Mathi
Mathi

Reputation: 301

How to install a .sh script?

I have written a script named "installcms.sh" and i placed it /root

This is my script

apt-get install python-setuptools python-imaging >> installcms.log > 2>&1


easy_install pip >> installcms.log > 2>&1

pip install django django-cms south django-appmedia >> installcms.log > 2>&1

django-admin.py startproject djangocmsproject >> installcms.log > 2>&1

cd djangocmsproject

rm settings.py

rm urls.py

cp /root/settings.py settings.py >> installcms.log > 2>&1

cp /root/urls.py urls.py >> installcms.log > 2>&1

mkdir templates

cd templates

cp /root/example.html example.html >> installcms.log > 2>&1

cd ..

python manage.py syncdb --all >> installcms.log > 2>&1

python manage.py migrate --fake >> installcms.log > 2>&1

python manage.py runserver >> installcms.log > 2>&1

When i try to execute my script using the command "/root/installcms.sh"

I am getting this error

****/root/installcms.sh: line 2: syntax error near unexpected token `2'**

**/root/installcms.sh: line 2: `apt-get install python-setuptools python-imaging >> installcms.log > 2>&1'****

Upvotes: 0

Views: 511

Answers (2)

gotson
gotson

Reputation: 3907

From the error messages your script is incorrect.

The following redirection is not valid: >> installcms.log > 2>&1

It should be: >> installcms.log 2>&1

You can check http://www.tldp.org/LDP/abs/html/io-redirection.html for further explanations on how redirection works in bash

(i assumed your default shell is bash, but redirection in other shells should be the same)

Upvotes: 1

johnsyweb
johnsyweb

Reputation: 141790

This:

>> installcms.log > 2>&1

Should be:

>> installcms.log 2>&1

Upvotes: 0

Related Questions