I have the following line in my bash file:
LIST=$(ssh 192.168.0.22 'ls -1 /web');
The problem I am having is that it is a part of automated script and I often get this on the stdout and not the data I need:
ssh_exchange_identification: Connection closed by remote host
I realize that LIST only gets the stdout of the ls. So I am looking for a command that would get more of the info from the commands. In particular:
stdoutforls- I have that right nowstderrforls- not really interested, I don't expect a problem therestdoutforssh- Not interested, I don't even know what it would outputstderrforssh- THIS IS WHAT I AM LOOKING FOR to check whether itsshcorrectly. This being empty should mean that I have the data in$LISTI expect
stdoutof thels, and I need that. – Patrick Kusebauch Jan 28 '17 at 21:44sshconnection produce error simultaneously withlsproducing output ? If not, what's going to be stored in the variable is eitherssh'sstderrorls'sstdout– Sergiy Kolodyazhnyy Jan 28 '17 at 21:46$?variable. If there was an error, it would be equal to non-zero value. I'll add example in a moment. – Sergiy Kolodyazhnyy Jan 28 '17 at 21:50$?will also be non-zero if thelsfails. – Kusalananda Jan 28 '17 at 22:03lsand when something went wrong. – Patrick Kusebauch Jan 28 '17 at 22:09