Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Sys::IP

by idnopheq (Chaplain)
on Apr 04, 2001 at 14:32 UTC ( #69609=note: print w/ replies, xml ) Need Help??


in reply to Sys::IP

I tested this on a RedHat 7 box w/ 5.6.0. It failed with

Undefined subroutine &Sys::IP::SUPPORTED called at /usr/lib/perl5/site_perl/5.6.0/Sys/IP.pm line 27. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.6.0/Sys/IP.pm line 28. Compilation failed in require at ./getip.pl line 5. BEGIN failed--compilation aborted at ./getip.pl line 5.

I think the BEGIN block doesn't like looking for a sub not included in the block. So, I tested my theory with the following adjustment:

#--------------------------------------------------------------------- +-------# #we want to die if a system isn't explicitly supported BEGIN { #these are the os's that are supported at this time my @Supported = ( 'openbsd', 'freebsd', 'linux', 'irix', 'solaris', 'darwin', 'MSWin32' ); grep /$^O/, @Supported or die "$^O isn't supported by Sys:IP yet.\n"; }

I've been up all night, so this could be made better, but it works. Here is my test code:

#!/usr/bin/perl -w #-*-perl-*- use strict; use Sys::IP; use diagnostics; my $ip = ip(); my @ips = ips(); print $ip , "\n"; foreach ( @ips ) { print $_ , "\n"; }

BTW, MSWin32 uses 'ipconfig /all' for the type of data you need. I think it sits in %SystemRoot%/system32 on NT/2k and %SystemRoot%/command on 98/ME, but I could be wrong. By default, if networking is installed, ipconfig should reside in the PATH env var. I'll check it for you when I get in to work.

HTH
Dex


Comment on Re: Sys::IP
Select or Download Code
Re: Re: Sys::IP
by BlueLines (Hermit) on Apr 05, 2001 at 14:27 UTC
    heh, i _knew_ that BEGIN foolishness wasn't going to do what i thought it would. I was constantly doing the following:
    nooky:~$ sudo cp IP.pm /usr/lib/perl5/5.6.0/i386-linux/Sys/ nooky:~$ perl -MSys::IP -e 'print ips()'
    over and over again. I must not have tested the BEGIN version (I originally did what you did). But thanks for the feedback. I'm fixing that, and I'll try the new Win32 stuff, and if all goes well, I'll ship it off to CPAN.

    BlueLines

    Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69609]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-09-20 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls