Silly me! Before everybody decide to embarrass me, here is my stupid
mistake: a line is passed from "client" complete with its newline
character. Putting a "chop;" statement before $output solves my
problem. As usual, a question has to be asked before I can find the
answer myself.
--
Johanes Suhardjo (joh...@farida.cc.nd.edu)
--
Drive defensively. Buy a tank.
I tried
$command = 'touch /test';
$output = `$command 2>&1`;
print "hahaha: $output hihihi:\n";
it gave me
hahaha: touch: cannot create /test: Permission denied
hihihi:
which was okay.
Now if I pass the command through a socket (pp. 342-345 Camel book),
it doesn't redirect STDERR to $output.
For example
in "server":
select(NS); # NS is the socket to communicate with "client"
while (<NS>) {
# print "$con: $_";
$output = `$_ 2>&1`; # Somehow STDERR doesn't go to $output.
print "hahaha: $output hihihi:\n";
}
when I typed
touch /test
in "client", the output on "client" window was:
hahaha: hihihi:
while the error message
touch: cannot create /test: Permission denied
was displayed on "server" window.
Can somebody tell me why? Thanks.
--
Johanes Suhardjo (joh...@farida.cc.nd.edu)
--
Antonym, n.:
The opposite of the word you're trying to think of.
You need to chop the newline on $_ before using it in a command. The
newline turns it into two commands, the second of which doesn't do much.
(When reading from a socket connected to Who Knows What, bear in mind you
might also have to chop a carriage return.)
Larry