shell - how to check ssh exit command executed? -
i want check exit
command executed success in ssh session.
my first attempt using command exit && echo $? || echo $?
.the echo $? || echo $?
,it should print 0 if exit successful.
problem echo
never execute if exit
execute success because connection disconnected , later command lost.
my second attempt splitting command 2 command, this:
$ exit $ echo $?
echo $?
should 0
if exit
execute successful.
problem echo $?
maybe swallowed because send arrived remote ssh host before exit
executed.
so, how ensure exit
executed @ remote host before send next command?
update
using stage execute shell command @ program language , send message ssh pipe stream.so, don't know exit command executed time.if exit command not completed, follow commands swallowed because send exiting host. why i'm care exit command executed.
if main concern knowing local machine, define variable earlier in script known on local machine before ssh. after exiting test existence of variable. if exists on local machine , if not try exit again because not on local machine.
#define before ssh uniquevarname333=1
then in script:
# ssh stuff exit if [ -z ${uniquevarname333+x} ]; exit; else echo "back on local machine"; fi
or check success of exit multiple times ensure successful when command remote machine.
exit || exit || exit #check many times feel probability of exiting close 0
Comments
Post a Comment