0

is it possible to get the standard output from remote machine - 100 or 1 , After ruining the script /tmp/script.bash ?

 ssh $remote_machine /tmp/script.bash

 echo $? ( from remote machine script - not from ssh ! )

on remote machine -

 more /tmp/script.badsh

 #!/bin/bash

 command

 [[ $? -eq 0 ]] && exit 100 || exit 1

1 Answer 1

2

It seems that you want the exit value from the remote script ( $?) and not stdout (the scripts output as per your title)

The ssh man page says this

ssh exits with the exit status of the remote command or with 255 if an error occurred.

So if your script is working correctly it will return 100. If it's not then there are a few possibilities

  • command is not exiting with 0
  • your [[ ... ]] is incorrect which looks right, I think that - eq should be -eq1.

1OP has edited their question and removed the obvious error from point 2 above. We are left to conclude that point 1 is correct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .