Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Perl: local IP info w/o knowing
Name: R Wideman Date: October 16, 2002 at 20:17:55 Pacific OS: win2k CPU/Ram: doesnt matter
Comment:
I am wanting to get my IP and Hostname via PERL w/o knowing either the ip or the hostname. Is there a way to do this? It seems that this is the closest to what i want but its requiring know info and also it doesnt print out anything:
#!perl use Socket; $ip=gethostbyname 'hostname'; print "My IP Address is: $ip";
Name: JSLover Date: October 19, 2002 at 22:12:29 Pacific
Reply:
The ip of the computer you're running the script on right? Not have a server tell you your ip? To get the ip/hostname of the server running the script...use...
#!/usr/bin/perl $ip="$ENV{'SERVER_ADDR'}"; $hostname="$ENV{'SERVER_NAME'}"; print "My IP Address is: $ip\n"; print "My Hostname is: $hostname";
...or more directly...
#!/usr/bin/perl print "My IP Address is: $ENV{'SERVER_ADDR'}\n"; print "My Hostname is: $ENV{'SERVER_NAME'}\n";
I just noticed you said your OS is Win2K...you don't need the 1st line in the file... #!/usr/bin/perl ...I'm not sure if it'll mess anything up by being there on Win2K but if it don't give an error leave it unless you'll never use it on a unix then delete.
Summary: Here's a tough question for the Perl experts. I need to write a script to automate the task of verifying the status of the SCSI RAID arrays from our (100+) servers. Most are Novel 5.1 with a few W2K ...
Summary: I send out an email every day through a command line email program. The email gets the subject from a text file that I create. When I get the email in Outlook 2003, it removes the extra line breaks ...
Summary: Not necessarily a waste of time. Only a waste if you start the project without some analysis. Hehe, I think for me this was strictly a waste of time :) I have no idea why I started doing this as a bat...