Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Apr 1998 23:37:35 -0400
From:      Chado <chado@p3.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Ping program not working from cron
Message-ID:  <3.0.3.32.19980408233735.0090d270@popmail.p3.net>

next in thread | raw e-mail | index | archive | help
Gents,

I have written a program that pings hosts on our network and the internet.

When I run it from the command line it works fine...but when I install it
in the cron it doesnt find any of the local machines.

Here is an output of my routing tables (netstat -r):

bash$ netstat -r
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use     Netif Expire
default            gateway            UGSc        5        0       ed0
localhost          localhost          UH          0       18       lo0
20.12.12/25        link#1             UC          0        0 
gateway            0:e0:1e:b9:bf:d2   UHLW        6       36       ed0   1163
server1            0:40:33:54:7a:1e   UHLW        1      134       lo0

Its really weird that it would work from the command line but not cron.

Here is a copy of the program:

#!/usr/local/bin/perl -w
$host ="192.168.0.3"; #can be local or other machine IPs
@output =`ping -c 3 $host`;
for $test ( @output ) {
  if ( $test =~ /^64/ ) { $i = 1; }
}
if ( $i ) {
  print "Host was reachable\n";
} else {
  print "Could not reach host\n";
}

If anyone has any ideas I would really appreciate them.

Thanks,

JS

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.3.32.19980408233735.0090d270>