Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re:**3 (rob_au) Getting net addy on localhost?

by rob_au (Abbot)
on Nov 27, 2001 at 10:17 UTC ( #127738=note: print w/replies, xml ) Need Help??


in reply to Re:**3 (rob_au) Getting net addy on localhost?
in thread Getting net addy on localhost?

The method that I pointed out in the addendum to my first post in this thread *should* suffice if you are wanting to resolve the default external IP address of the machine - But I do agree, there is a great amount of 'grey area' on this question given the number of available configurations and methods of interface.

I don't however agree with the concept of parsing /etc/sysconfig/network-scripts/ifcfg-* - For starters, this is very much a Red Hat (and variant) locale for network configurations, *not* a general *NIX location pragma. Further to this, the idea of relying on text files generated outside of the real scope of the program makes me very nervous - I have rambled on this concept previously and as such won't repeat myself here.

Suffice to say, if you are going to rely on *any* external source, consider it tainted and evil (-T, -T and -T) until proven otherwise - And even then treat it with care. If I had to rely on an external program source, then I would be looking directly at /sbin/ifconfig (the path of which should be hard-coded into the program, not drawn from an alternate configuration file) and parsing the output of that.

Just my random thoughts on the matter

 

Ooohhh, Rob no beer function well without!

Replies are listed 'Best First'.
Re:**5 (rob_au)**2 Getting net addy on localhost?
by belg4mit (Prior) on Nov 27, 2001 at 10:22 UTC
    Well I have seen /etc/sysoncfig/network-scripts on other platforms. But I'll take your word on that. However this is one reason why I mentioned webmin which is ultra-cross-platform (even if a little ugly).

    The problem with calling something like ifconfig is relying upon a standard output scheme across platforms... I doubt Sun does it similar to anybody else (afterall they have their own cron, grep, and ping etc.) UPDATE: I do suppose this |P is a bit GNU-centric ;-).

    --
    perl -p -e "s/(?:\w);([st])/'\$1/mg"

      Yep, it seems we are thinking very much alike on this issue - And I do agree, having to rely on the output of *any* external program is less than ideal, but sometimes system permissions and available utilities limit choices.

      The output of /sbin/ifconfig however I think you would find to be much more uniform than the availability of /etc/sysconfig/network-scripts/ifcfg-* files across *NIX platforms - I know for example that my Debian servers don't use these configuration files and so this locale pragma for network configuration cannot even be seen to be consistent across Linux distributions, let alone *NIX platforms.

      Oh, how I yearn for a consistent WIN32 API ... No, hang on a minute, no I don't ... ;-)

       

      Ooohhh, Rob no beer function well without!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2021-10-23 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?