View Single Post
Old 06-28-2006   #1 (permalink)
thecubed
Yup, that's meee!
 
thecubed's Avatar
 
Join Date: Jun 2004
Location: Infront of my screen (most of the time)
Posts: 89

Send a message via AIM to thecubed Send a message via Yahoo to thecubed Send a message via Skype™ to thecubed
PERL - extracting output of ifconfig to get local system IP address...

Hello again!

I was wondering if anyone knew how to extract the output of /sbin/ifconfig on a Linux system, and feed it into a Perl variable.
The reason for this is that I am building a computer that will run without a monitor, keyboard, or mouse, and will act as a network video streamer... it has an internal charactor LCD that will be used to display ip address and other statistics of the machine (see http://thecubed.com/tc-blog/?p=6 ).
I am using a program called LCDd (part of LCDproc) to control the LCD and yaLCD (a perl script) to display the information. yaLCD doesn't output the local system's ip address to the LCD screen, so I wanted to modify it.

I've already scoured the internet for answers, and I've only come up with a few things...
I've found this snippet of code, but it only prints "1", and nothing else.
Code:
 my $ip = ((`/sbin/ifconfig eth0`)[1] =~ /inet addr:(\S+)/);
 print $ip;
I know a bit of Perl (it's just like PHP, only more complicated ), but not enough to tell me why this won't work...

Any help is appreciated,
Thanks!
__________________

www.thecubed.com <--- TheCubed Homepage!
thecubed is offline