CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
automatic NSlookup and Grep IP address

 



quantumdecipher
New User

Oct 2, 2011, 2:56 AM

Post #1 of 1 (474 views)
automatic NSlookup and Grep IP address Can't Post

Hi, I'm a beginner in Perl. I'm self studying and I am trying out a simple program. Basically, I want to do a program which will automate nslookup and ping, then append the output to a file created on the start of the script. here is what i have so far:

if(-e "ipPool.out") {system("del ipPool.out")}

system("cls");
print "Enter Controller Number : ";
$contNum = <STDIN>;
chomp($contNum);
print "Enter Port Number for : ";
$portNum = <STDIN>;
chomp($portNum);
print "How many partitions to get : ";
$parNum = <STDIN>;
chomp($parNum);

open(FILE, ">>ipPool.out") || die "Could not open Output File!";
print FILE "IP Pool for Partitions\n=====================\n\n";
$count = 1;
while ($count <= $parNum) {
chomp($count);
my(@lookup) = `nslookup ss$contNum-$portNum-net7`;
$IPAddress = exec "ifconfig eth1 | grep 'Address:' | cut -d: -f2 | awk '{print $1}'";
print FILE "$contNum-$portNum\n======\n\n@lookup\n\n";
$count++;
}
close(FILE);
system("cls");
system("more ipPool.out");

so basically, i want the script to ask how many partitions the user needs an ip address reserved. then the script will issue the nslookup command the number of times the user inputs, then append to an existing file created during program start.

thanks!
Absence of evidence is not evidence of absence.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives