alt
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tech Articles arrow UNIX arrow An Introduction to Shell Scripting
Site Search


An Introduction to Shell Scripting

Basic Definition of Shell Scripting is Storing Frequently Used Commands in Files.

Store the following in a file named simple.sh and execute it.

#!/bin/sh# Generate some useful info for# use at the start of the daydatecallast $USER | head -6

Shows current date, calendar, and a six of your previous logins for security check. You might run this at the beginning of each day.Notice that the commands themselves are not displayed, only the results.To display the commands verbatim as they run, execute with sh -v simple.sh.

To echo the commands after variable translation, execute with sh -x simple.sh

With -v or -x (or both) you can easily relate any error message that may appear to the command that generated it

When an error occurs in a script, the script continues executing at the next command Verify this by changing 'cal' to 'caal' to force an error, and then run the script again Run the 'caal' script with 'sh -v simple.sh' and 'sh -x simple.sh' and verify the error message comes from cal

Now you can re-use commands easily and save some typing and mistakes


Trackback(0)
Comments (2)add comment

spshant said:

  The training materials is very limited. It would be a great resource site if Training section is given a little more structured organisation.
Just a thought from a user pov.
Thx,
Prashant
May 17, 2004

sanereddy said:

  Thanks Prashanth for your comments. We have added a new section EFS Directory with all the ebooks and tuturials for most of the topics.

Thanks for your comment.
June 19, 2004

Write comment

busy
 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape