Foil 11 - Running commands on remote systems (1/2)

 1 #*********************************************************************
 2 # Complex example showing the automation of remote system support in *
 3 # a multi-platform distributed environment.                          *
 4 #*********************************************************************
 5 
 6 #***************** Select commands for this server *******************
 7 server_type=`uname`
 8 case $server_type in
 9   SunOS )
10     rsh_cmd=rsh             # sun
11     ping_cmd='ping "$client" 16 1 >/dev/null 2>&1;echo `expr 1 - $?`'
12   ;;                          
13   HP-UX )
14     rsh_cmd=remsh           # hp
15     ping_cmd='ping "${client}" 16 1 |grep "1 packet"|wc|cut -d" " -f1'
16   ;;
17   ULTRIX )
18     rsh_cmd=rsh             # ultrix
19     ping_cmd='ping "${client}" >/dev/null 2>&1;echo `expr 1 - $?`'
20   ;;
21   * )
22     echo '^G'   # Error message highlight and beep
23     echo "Unsupported system being used, value=$server_type"
24   ;;
25 esac # End of case                                                 #11

This is the first of five slides showing the more complex, but very useful of performing operations on remote systems. This can be used for distributing software, checking processes, changing configuration files, rebooting, etc.

There are actually two separate but related examples. The first two slides show a basic operation while the last three expand the second slide with more complicated handling of different operating environments on the remote hosts.

The first slide deals with the main system that will be controlling the remote systems. First we get the type of operating system we are running on, then select commands and options that will work. Other commands, directories, etc. may be added or deleted as needed.

  • Some systems "rsh" for "remote shell" while others use this for "restricted shell" and use "remsh" instead.
  • The syntax of the ping command also varies and we build our own command string that will give the same results on different platforms.

    Remote shell is no longer recommended due to security concerns. Other commands should be used if they are available.

    The ping commands may use return codes or a count lines returned depending on the capabilities of the system. Return codes are very inconsistent across platforms.

    Previous   Next   Index