alt
Advertisement
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tech Articles arrow UNIX arrow What is Shell Scripting
Site Search


What is 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 day
date
cal
last $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

Other standard variable names include: HOME, PATH, TERM, PAGER, PRINTER


Trackback(0)
Comments (0)add comment

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