Home

Advertisement

Customize

Shantanu Oak - February 12th, 2008

Feb. 12th, 2008

03:59 pm - Python and Bash

Now in this file (myfirstscript.sh), enter the following line.

#!/usr/bin/bash
ls -l
sleep 2
who
sleep 2
w

Nothing spectacular here. But note that 'sleep' is an internal bash command which is used to pause the execution process for certain time in seconds. Next fire up a console (xterm, gnome-terminal ...) and set the executable bit for the script myfirstscript.sh as follows :

$ chmod u+x myfirstscript.sh

This lets you execute the script by its name as follows :

$ ./myfirstscript.sh

All this may seem easy. But you can get added benefits if you substitute 'bash' with Python language to write your scripts. If you do not know Python language and is looking for some direction then you should look at the two books Core Python programming and Python phrasebook which will give you a head start in mastering this powerful but easy to learn language.

http://linuxhelp.blogspot.com/2008/02/python-scripts-vs-bash-scripts-in-linux.html

Tags: ,
Current Mood: geeky
Previous day (Calendar) Next day