lcollins has asked for the wisdom of the Perl Monks concerning the following question:
Look in hash for stuff from miss. (sorry for all the code).#!/usr/bin/perl -w my $dir="/home/lcollins"; system "/bin/cat /dev/null > $dir/miss"; open (HOSTS,"$dir/ClockIP") or die "Can't open HOSTS $!"; open (MISS,">>$dir/miss") or die "Can't open miss $!"; my $miss=<MISS>; while (<HOSTS>) { chomp; @args = ("/bin/ping $_ -c 2"); system(@args) == 0 or print MISS "$_\n" } print "Done.";
#!/usr/bin/perl -w my $dir="/home/lcollins"; open MISS, "$dir/miss" or die "can't open $!"; %clocks=( "start"=>"000", "10.1.0.15"=>"0", "10.20.20.13"=>"1FL Sadlier", "10.20.11.15"=>"Convent", "10.20.44.15"=>"1 Cooke", "10.20.44.16"=>"2 Cooke", "10.20.46.36"=>"6 Cooke", "10.20.46.37"=>"4 Cooke", "10.20.46.38"=>"5 Cooke", "10.3.0.15"=>"Beacon", "10.3.0.16"=>"Beacon", "10.4.0.15"=>"9G", "10.6.0.15"=>"Comm Diss", "END"=>"000" ); my $miss=<MISS>; #chomp $miss; #print "Before loop $miss\n"; foreach (<MISS>){ chomp; #print "in loop $_ \n"; if (exists $clocks{$_}){ print "$_ is down\n"; } close MISS; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print to a file then use file content for test?
by osunderdog (Deacon) on Jan 04, 2005 at 22:27 UTC | |
by ikegami (Patriarch) on Jan 04, 2005 at 22:47 UTC | |
by lcollins (Novice) on Jan 05, 2005 at 12:57 UTC | |
by ikegami (Patriarch) on Jan 05, 2005 at 15:23 UTC | |
by lcollins (Novice) on Jan 05, 2005 at 18:27 UTC | |
| |
by lcollins (Novice) on Jan 05, 2005 at 14:44 UTC | |
by lcollins (Novice) on Jan 05, 2005 at 18:28 UTC |