Exforsys.com
 
Home Tech Articles UNIX
 

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


Read Next: Installing Solaris 8 x86Installing Solaris 8 x86



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape