AIX > Tips & Techniques > Miscellaneous

AIX Shell Scripting Made Simple


Shell scripting is much like having a power tool instead of using a screwdriver, although as with everything else, it's always prudent to have the right tool for the right job. You might not need a power tool to screw in a single screw, but if you have 200 screws, you’ll appreciate the power tool.

It’s the same with shell scripting. If you need to pull information from multiple servers, instead of logging into each individually, you can write a basic shell script to perform that function. Let's dissect a basic shell script. This example is a simple script to report OS levels:

#!/bin/sh

#Variables
_list_of_servers="mars earth saturn jupiter"

# Main Code
for _server in $_list_of_servers
do
  echo "$_server OS Level:"
  ssh $_server "oslevel -s"
  echo "\n"
done

Now this script is going to go out and report the OS level from servers: mars, earth, saturn and jupiter. If you run the script ./script.sh you'll get the following output:

mars
6100-06-04-1112

earth
6100-06-04-1112

saturn
6100-06-04-1112

jupiter
6100-06-04-1112


Andrew Wojnarek is a systems engineer with ATS Group and an IBM Champion.


comments powered by Disqus

Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

AIX > TIPS & TECHNIQUES > MISCELLANEOUS

Application Testing: Giving Users What They Need

AIX > TIPS & TECHNIQUES > MISCELLANEOUS

Change Management: Approval Must Be Earned

AIX > TIPS & TECHNIQUES > MISCELLANEOUS

Making Changes: Prudence and Discipline Always

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters