问题
I am running a script from remote machine via ssh:
ssh 'some_cmd;my_script'
Now, I want to store exit status of shell script on my local machine. How can I do it?
回答1:
Assuming nothing goes wrong with ssh
itself, its exit status is the exit status of the last command executed on the remote host. (If something does go wrong, its exit status is 255.)
$ ssh remotehost exit 13
$ echo $?
13
来源:https://stackoverflow.com/questions/37701143/how-to-get-exit-code-of-remote-command-through-ssh