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