How to get exit code of remote command through ssh

夙愿已清 提交于 2021-02-07 20:28:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!