On Thu, 4 Oct 2001, Daniel Falkenberg wrote:
> List,
>
> Can some one help me with opening ifconfig and pipe it to a text file.
> Then I want to be able to view that file.
>
> How would I go about this?
>
> open IFCONFIG, "/sbin/ifconfig";
> $file=<IFCONFIG>;
> print $file;
You've almost got it:
open(IFCONFIG, "/sbin/ifconfig |") or die 'Couldn't fork: $!\n";
while(<IFCONFIG>) {
printf if /eth0/; #for example
}
This forks off the ifconfig process, and the piped output is treated as if
you have opened a file for input. Then you just process until there is no
more input, as you would any filehandle.
-- Brett
http://www.chapelperilous.net/
------------------------------------------------------------------------
Bing's Rule:
Don't try to stem the tide -- move the beach.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]