AIX > Tips & Techniques > Miscellaneous

AIX Shell Scripting Made Simple


Bookmark and Share

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.

Advertisement

Buyers Guide

Search our new 2013 Buyer's Guide.

Search Companies


Search Products


Advertisement

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link

Related Articles

Consolidate AIX 5.2 Workloads

Web Exclusive | Versioned WPARs enable legacy applications on POWER7

Knowledge Is Power

E-Newsletter | Tips for a Smooth Handoff of Power Systems Knowledge