Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] automatic NSlookup and Grep IP address

Expand Messages
  • Amish Husain
    on a side note indent your code to make it readable... http://en.wikipedia.org/wiki/Indent_style ________________________________ From: whysoserious?
    Message 1 of 3 , Oct 6, 2011
    • 0 Attachment
      on a side note indent your code to make it readable...

      http://en.wikipedia.org/wiki/Indent_style


      ________________________________
      From: whysoserious? <chestersigua@...>
      To: perl-beginner@yahoogroups.com
      Sent: Thursday, October 6, 2011 4:55 AM
      Subject: [PBML] automatic NSlookup and Grep IP address


       
      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!




      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.