Re: ssh stderr question

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

 



On 09Apr2017 13:57, Samuel Sieb <samuel@xxxxxxxx> wrote:
On 04/09/2017 07:23 AM, bruce wrote:
the following test works..

ssh  user_foo@1.2.3.4 pgrep -f  'master_app' | wc -l

however, i realized that in some cases I was seeing a "ssh connection
timeout" so I looked into how to capture the complete STDERR from the
local side.

ssh  user_foo@1.2.3.4 "pgrep -f  'master_app' | wc -l " 1>&2

runs but not sure it will actually do what I want...

commands are very different from each other. The first one will run the "wc -l" on the local computer and the second one will run it on the remote computer. The "1>&2" will redirect the stdout to stderr, so all your output will be coming out in stderr. If you want to include stderr in stdout, use "2>&1". If you just want to save stderr somewhere, you can use "2>filename".

All very pertinent points. Just to add one:

if you're doing the first command (ssh ... | wc ...) then your redirections apply only to the "wc". You seem to want the stderr from the ssh. For that you need to go:

 ssh .... 2>filename | wc -l

One reason that you may think the two commands are the same is that functionally they pretty much are because wc (as invoked) read from stdin and writes to stdout, and so it doesn't matter whether it runs locally or remote.

As a matter of practive I tend to run as little as possibly remotely, so I would use your first invocation (remote pgrep, local wc) if there wasn't a special reason otherwise.

Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux