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:
stdout
forls
- I have that right nowstderr
forls
- not really interested, I don't expect a problem therestdout
forssh
- Not interested, I don't even know what it would outputstderr
forssh
- THIS IS WHAT I AM LOOKING FOR to check whether itssh
correctly. This being empty should mean that I have the data in$LIST
I expect
stdout
of thels
, and I need that. – Patrick Kusebauch Jan 28 '17 at 21:44ssh
connection produce error simultaneously withls
producing output ? If not, what's going to be stored in the variable is eitherssh
'sstderr
orls
'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 thels
fails. – Kusalananda Jan 28 '17 at 22:03ls
and when something went wrong. – Patrick Kusebauch Jan 28 '17 at 22:09