1

I am trying to set a variable in a Bash script to the results of running a command on a remote machine via rsh with a timeout option, such as...

timeout -s KILL 2 rsh jane df -h | grep StorageMedia
                  2.7T  2.1T  607G  78% /mnt/StorageMedia

I have tried the following...

rshresult="$(timeout -s KILL 3 rsh remotemachine df -h | grep StorageMedia)"

and

rshresult=`timeout -s KILL 3 rsh remotemachine df -h | grep StorageMedia`

...but both timeout after 3 seconds without setting $rshresult.

Running

  • What are you expecting `rshresult` to be when the command is killed due to timeout? – that other guy Jun 11 '15 at 15:14
  • Both examples return the words 'Killed' rather than the expected results – Ian Malcolm Jun 11 '15 at 16:11
  • Does the command always finish within 3 seconds otherwise, so that a 30 second timeout makes no difference except taking longer? Does `timeout -s KILL 2 rsh remotemachine df -h | grep StorageMedia | cat` finish successfully, without you interrupting it in any way? Are there any other messages? – that other guy Jun 11 '15 at 19:59
  • It usually finishes within a few seconds, but I've had a few occasions where it never completes at all – Ian Malcolm Jun 12 '15 at 17:14

0 Answers0