Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. if ($#ARGV != 1)
  4. {
  5. print "usage ./lab3 forward reverse";
  6. }
  7.  
  8. open($file1, $ARGV[0]) or die "cannot open file";
  9. open($file2, $ARGV[1]) or die "cannot open file";
  10. $counter = 0;
  11. $counter2 = 0;
  12.  
  13. print "\n";
  14. print "Forward Zone File:\n";
  15. while ($line = <$file1>)
  16. {
  17. if ($line =~ /in\s+a/ig)
  18. {
  19. @array = split(" ", $line);
  20. $hostnamecontents[$counter] = $array;
  21. $hostnamecontents[$counter] = $array[0];
  22.  
  23. print $hostnamecontents[$counter];
  24. print "\n";
  25.  
  26. @ipadd = split('\.', $array[3]);
  27. $ipfor[$counter2] = $ipadd;
  28. $ipcontents[$counter] = $ipadd[3];
  29.  
  30. print $ipcontents[$counter];
  31. print "\n";
  32.  
  33. $counter++;
  34. }
  35.  
  36. }
  37. print "\n";
  38. print "Reverse Zone File:\n";
  39. while($line2 = <$file2>)
  40. {
  41. if ($line2 =~ /in\s+ptr/ig)
  42. {
  43. @array2 = split(" ", $line2);
  44.  
  45. @rhostname2 = split('\.', $array2[3]);
  46. $rhostfor[$counter2] = $rhostname2;
  47. $rhostnamecontents[$counter2] = $rhostname2[0];
  48. $rip2[$counter2] = $array2[0];
  49.  
  50. print "$rhostnamecontents[$counter2]\n";
  51. print "$rip2[$counter2]";
  52. print "\n";
  53.  
  54. $counter2++;
  55. }
  56. }
  57. print "\n";
  58. for ($i=0, $i<$counter2, $i++)
  59. {
  60. $ipcombined = join(".", $ipadd[$i]);
  61. print "ip is: $ipcombined\n";
  62. }
  63.  
  64. close ($file1, $file2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement