in reply to Re: how does '2>&1' work ?
in thread how does '2>&1' work ?

But I do encounter such a question:

case 1:

 use strict;  my $cmd = "dumpcap -i eth0 -b duration:10 -w \\media\\Work\\abc.pcap";  `$cmd`

"dumpcap" itself will print some infomation, if I add 2>&1 behind $cmd, such as `$cmd 2>&1`, no infomation displayed. But if I do not add 2>&1, information do displays

in another case, If I change $cmd to :

 my $cmd = "ifconfig";

There is no information displayed in shell no matter If I add 2>&1 or not

Why is this difference ?

Replies are listed 'Best First'.
Re^3: how does '2>&1' work ?
by ikegami (Patriarch) on Feb 23, 2011 at 06:10 UTC
    That means that dumpcap printed some information to STDERR and ifconfig didn't.

      Great! I got it. Thanks a lot :)

Re^3: how does '2>&1' work ?
by Anonymous Monk on Feb 23, 2011 at 05:01 UTC
    Why is this difference ?

    Why is dumpcap different from ifconfig? Because it wants to be different?