I am trying to execute OS cmds on multiple host using via pssh. The problem is stderr is not printing in same line.
I am managed to print cmd output in same line but not stderr. 55
Stderr: ssh: Could, not, not known [2] 04:58:09 [], host2, /root/file1 [3] 04:58:10 [], host3, Stderr: ls: cannot, access, /root/file1: No such file or directory [4] 04:58:10 [], host4, /root/file1
Can I get similar output as below?
[1] 04:41:52 [], host1, Exited with error code 255, Stderr: ssh: Could not, re
[2] 04:41:52 [], host2, This is FILE1, Linux host2 3.0.101-0.47.52-default #1 SMP Thu Mar 26 10
[3] 04:41:52 [], host3, Stderr: cat: /root/file1: No such file or directory, Linux host3 3.0.101-108.68-defaul
[4] 04:41:52 [], host4, Stderr: cat: /root/file1: No such file or directory99-default64 x86_64 ..
[5] 04:41:53 [], host5, This is FILE1 $$$$$, Linux host5 4.4.162-94.72-default #64 x86_64 x86_64 GNU/Linux
If you consider that your stderr is already redirected to your stdout:
awk:
if this is not the case, you will have to either use
2>&1 |
or if your bash is >= to version 4 use|&