Re: Differentiating between ssh connection failures and ssh command failures

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On Sat, Sep 12, 2015 at 11:14:07AM +1000, Damien Miller wrote:
> ssh server.example.com /usr/bin/do/something
> r=$?
> if [ $r -eq 0 ] ; then
> 	echo success
> elif [ $r -eq 255 ] ; then
> 	echo ssh failed
> else
> 	echo command failed
> fi


ssh remoteserver exit 255

Hmm :-)

exit(-1)  aka exit(255) is a pretty standard "generic failure code"
for many programs.

The problem, really, is that "exit code" is the wrong thing to test for.

x=`ssh remoteserver "echo CONNECTED && somecommand"`

And then see if CONNECTED appears in the output to show successful
connection.

-- 

rgds
Stephen
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux