HSTuners

HSTuners (http://www.hstuners.com/forums/index.php)
-   For The Geek In You (http://www.hstuners.com/forums/forumdisplay.php?f=104)
-   -   Please help with Perl program! (http://www.hstuners.com/forums/showthread.php?t=14594)

94_AcCoRd_EX 04-15-2003 11:22 PM

Please help with Perl program!
 
Here's all I know about the assignment:

/proc/net/dev - Identify how many ethernet devices that I have and identify which one is "upstream" by looking at the default route.

example output:
eth0 192.168.2.2
eth1 128.193.2.2 upstream


Can anyone give me a hand here? I know a few of you are experienced with networks and programming. I've never touched perl before.

Thanks :)

Maxvla 04-16-2003 01:41 AM

good luck ;)

spoogenet 04-16-2003 09:18 AM

Is this a school project or something???

I don't know enough about networking to be of too much assistance. I can help on a limited scale with specific perl questions, but usually I just go across the hall and get someone else to help me with the perl questions. :)

b

94_AcCoRd_EX 04-16-2003 11:52 AM

Quote:

Originally posted by spoogenet
Is this a school project or something???



Yeah it is :o

ebpda9 04-16-2003 06:58 PM

so that is under a unix/linux system right ???? well the number of ethernet devices is pretty simple to figure out: the last number +1.

94_AcCoRd_EX 04-16-2003 07:07 PM

Quote:

Originally posted by hondaman-iac
so that is under a unix/linux system right ???? well the number of ethernet devices is pretty simple to figure out: the last number +1.


Yeah, its for *nix. I understand what you're saying, but that's assuming that the system always numbers the devices in order starting with 0. I think that's reasonable to assume, but I'll do a little research.

Its due tomorrow morning :o

ebpda9 04-16-2003 08:22 PM

well from what i saw on my linux system (long time ago) every device starts with 0. the pimary hdd is blah blah/hdd0 the primary slave is blah blah/hdd2 and so forth.

Mushroom 04-17-2003 09:52 AM

hmm... not ethernet devices, though. I could run 2 cards on a solaris box as le0 and hme0. Count the unique IPs with your perl code to get the number of devices set. Not sure how to do so in perl, but essentially grep for "*.*.*.*", read number of lines without a comment hash before that pattern. get your output by redirecting lines from that file into another.

I think I could tcl it, but not perl.

94_AcCoRd_EX 04-17-2003 03:04 PM

I ended up using a complicated grep on /proc/net/dev to list the devices one per line. I then counted and displayed. Worked ok considering I'd never touched Perl before.


All times are GMT -5. The time now is 09:33 PM.

Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© 2006 HSTuners.com