On Thursday 17 June 2010 07:44 PM, Patrick O'Callaghan wrote: > On Thu, 2010-06-17 at 16:58 +0530, Jatin K wrote: > >> I've got the following[1] script from the Internet ( by >> googling ).... >> but it is not working :-( >> >> can anyone tell me what is wrong with it ???? >> > Not unless you explain what you mean by "not working". > > poc > > sorry for that actually I want to monitor the host in my network ( which host is alive and which is down ).I've following host ( subnet) 172.16.10.1 172.16.20.1 172.16.30.1 ......etc I want to monitor all the host through the single script ( I don't want to type the IP each time on CLI ). I have one text file with the host IP address in it ,which I want to monitor. I want to have a script that can read the ip from the file ...test the ping result and show the output on screen that host is alive or down. I also tried the following[1][2] two script combination it works fine with some error [3] [1]------- read the text file -------- #!/bin/bash for i in `cat /home/jk/office/branches` # path to the text file do ./test.pl $i # calling a script from the same path named test.pl [3] done [2]----------test.pl-------------------------------- #!/usr/bin/perl -w use strict; use Net::Ping; use Term::ANSIColor; # this is for colored output ( down host RED and alive GREEN ) my $pinghost=$ARGV[0]; if(!defined $pinghost){ print "Usage: $0 <ip address or hostname>\n"; exit; } my $p=Net::Ping->new("icmp", 2); for(;;) { #infinite loop unless($p->ping($pinghost)) { print color("red"),"$pinghost is down ",color("reset");" \n" } else { print color("blue"),"$pinghost is alive ",color("reset");" \n" #} sleep 10; #uncomment to continue ping } exit; #uncomment to ping once } [3]-------------------------------------------------out put of the above script ( with error )--------------------------------------------------------------------------- Useless use of a constant in void context at ./test.pl line 23. Useless use of a constant in void context at ./test.pl line 27. 172.16.10.1 is down Useless use of a constant in void context at ./test.pl line 23. Useless use of a constant in void context at ./test.pl line 27. 172.16.20.1 is alive Useless use of a constant in void context at ./test.pl line 23. Useless use of a constant in void context at ./test.pl line 27. ^C --- what is wrong with line 23 and 27 in test.pl ???? how to resolve this ??? -- °v° /(_)\ ^ ^ Jatin Khatri Registerd Linux user No #501175 www.counter.li.org No M$ -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines