dan@maccs.McMaster.CA (Dan Trottier) (09/30/88)
While in the process of rewritting our backup scripts I ran into a problem with the return status of rsh(1). I'm trying to do something (bourne shell) along the lines of: if rsh $host rdump ${level}${opt} ${dhost}:${dev} ${fs} > ${log} then echo "$host: $fs completed" else echo "$host: $fs failed" fi The problem is that rsh(1) doesn't return the exit status of the command it runs. Now I could write a script on the remote host that would be executed instead of rdump(8) but I would like to avoid adding or supporting software on those remote hosts. The script runs on a Sun 4/280 OS 4.0 and does remote dumps on various other machines. Any ideas? Thanks -- Dan Trottier dan@maccs.McMaster.CA Dept of Computer Science ...!uunet!utai!utgpu!maccs!dan McMaster University (416) 525-9140 x3444
D. Allen [CGL]) (10/04/88)
dan@maccs.McMaster.CA (Dan Trottier) writes: > The problem is that rsh(1) doesn't return the exit status of the command it > runs. Try a variant of this: #!/bin/sh PATH=/bin:/usr/bin:/usr/ucb; export PATH umask 022 status=` rsh somehost -n "somecommand && echo SUCCESS" 2>&1 ` case "$status" in SUCCESS) echo "${0}: it worked" ;; *) echo "${0}: it failed: $status" ;; esac If your command produces output, you may have to fiddle things a bit to get the SUCCESS onto stderr and only collect it. You can also change '&&' to ';' and echo the actual return status from the remote machine instead of the word SUCCESS. -- -IAN! (Ian! D. Allen) University of Waterloo