Problem with Cron tab

I have a script for pinging the switches and giving me the report:-
#!/usr/local/bin/perl
#!/bin/ksh
#!/usr/bin
#etc
`source /export/home/chinnigd/.profile`;
@names = `cat switches|cut -f1 -d' '`;
@ip = `cat switches|cut -f2 -d' '`;
$num = @names;
$re ="Empty";
$i = 0;
$flag = 0;
while ($i lt $num)
{
$ou = `ping $ip[$i]`;
if ( $ou == "no answer from $ip[$i]" )
{
print "ALERT!!The Switch is DOWN-->$names[$i]\n";
$flag = 1;
}
else
{
print "The Switch is up-->$names[$i]\n";
}
$i = $i + 1;
}
if ($flag -eq 0)
{
print "\n";
print "All the switches,totally $num Switches,in the network are UP\n";
print "
\n";
}

This script works fine in the command line but when I put it in the crontab, the cron job run at the specified time but the script doesn't work properly i.e. some commands in the script doesn't execute correctly and I always get the output as " All the switches. totally <> switches in the network are UP".

kindly help me how to solve this

hi

make sure that if u r accessing any file from particular path.. then specify complete path while accessing that file.

like u r reading a content of file - as name test. and
path for this file is bin/sql/proc/util/test.

then use this complete path -- as crontab assument system path by default.

Cheers

Regards
Swapneel

Thanks for your reply.
I gave the complete path of the file but still it doesn't work

instead of 'ping' alone

i used '/usr/sbin/ping..' and the problem went away
now the crontab is working perfectly

Thanks.