help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: shell-command


From: tomas
Subject: Re: shell-command
Date: Wed, 11 Jan 2017 16:28:58 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jan 11, 2017 at 03:11:51PM +0000, Kaushal Modi wrote:
> On Wed, Jan 11, 2017 at 3:46 AM Matthias Pfeifer <mpfeifer77@gmail.com>
> wrote:
> 
> > That was just what I was thinking. And I fear that I must have some very
> > basic misunderstanding here, but i was testing this before wrinting and
> > did:
> >
> > $ scp somefile somehost:/tmp 2> /dev/null
> >
> > I see the same output as usual...
> >
> 
> Correct, because that redirects only errors to /dev/null. The standard
> output is still sent to your default output device (terminal).

No. "ls" and "scp" behave differently:

# This is ls:

  tomas@rasputin:~$ ls > foo.stdout 2>foo.stderr
  tomas@rasputin:~$ ls -l foo.*
  -rw-r--r-- 1 tomas tomas    0 Jan 11 16:20 foo.stderr
  -rw-r--r-- 1 tomas tomas 1629 Jan 11 16:20 foo.stdout

# regular output goes to stdout; only error output goes to
# stderr (in this case, nothing)

# and this is scp:

  tomas@rasputin:~$ scp /etc/init.d tomas@localhost:/tmp > bar.stdout 
2>bar.stderr
  Enter passphrase for key '/home/tomas/.ssh/id_rsa': 
  tomas@rasputin:~$ ls -l bar*
  -rw-r--r-- 1 tomas tomas 32 Jan 11 16:21 bar.stderr
  -rw-r--r-- 1 tomas tomas  0 Jan 11 16:21 bar.stdout

# "regular" output goes to stderr, nothing to stdout

But note that scp most probably changes behavior whether it's "seeing"
a tty as its stdout and/or stderr. Beware!

What at first looks strange makes some sense if you think that scp's
"output" somehow is not the same as ls's output. The first one is
meant for human consumption whereas the latter is for both: human
and for piping into other programs. More or less.

(still have to check with sources, so take the above with a grain
of salt).

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlh2TzkACgkQBcgs9XrR2kYvRQCbBj1mI7ROj0IwWzzcmMvfZevL
HPsAn2F1GlFN113/bXnb5+1/xFd1I5cY
=Qr/o
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]