Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Ifconfig error capture

by kyle (Abbot)
on Mar 12, 2008 at 21:27 UTC ( [id://673831] : note . print w/replies, xml ) Need Help??

in reply to Ifconfig error capture

The message you're looking for comes out on STDERR, but the backticks only capture what comes out on STDOUT. What you can do is have the shell redirect the error stream to the normal output stream like so:

$code = `ifconfig eth0 hw ether $mac 2>&1`;

Replies are listed 'Best First'.
Re^2: Ifconfig error capture
by WalkingZero (Sexton) on Mar 12, 2008 at 22:01 UTC
    Oy! I knew it was something obvious. I actually had to redirect STDERR and also send STDOUT to /dev/null to properly capture the data, but once that was done i just turned my conditional slightly. using an unless statement to check if the $code was null or not. Thank you very much for helping me get past my own idiocy.

    "One future, two choices. Oppose them or let them destroy us" - Propaghandi