Re: ssh stderr question

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

 



On 04/10/2017 01:01 PM, Joe Zeff wrote:
On 04/10/2017 12:46 PM, Gordon Messmer wrote:

I did understand.  It doesn't matter if 2>file appears before the ssh
arguments, or at the end.  In both cases, ssh's stderr will be written
to a local file.  It is incorrect to say that the former example would
redirect wc's stderr, and not ssh.

Try this: put the ssh command in a shell script, let's say sshscript.sh. Then, ./sshscript.sh 2>stderr.log should do what you want. Please note that I haven't tried this, which is why I write "should," not "will."

In that case, ssh and wc's stderr will be written to stderr.log, just the same as the other two formats.

You don't have to take my word for it. You can test this. In all cases, stderr from the remote side is written to the local "stderr" file.

   $ ssh testhost cat ./write-to-stderr
   #!/bin/sh

   echo test stderr >&2
   $ ssh testhost ./write-to-stderr 2> stderr
   $ cat stderr
   test stderr
   $ rm stderr
   rm: remove regular file 'stderr'? y
   $ ssh testhost 2> stderr ./write-to-stderr
   $ cat stderr
   test stderr
   $ rm stderr
   rm: remove regular file 'stderr'? y
   $ cat ./ssh-write-to-stderr
   #!/bin/sh

   ssh testhost ./write-to-stderr
   $ ./ssh-write-to-stderr 2> stderr
   $ cat stderr
   test stderr

_______________________________________________
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