The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with cron job solne SUN Solaris 7 01-18-2008 08:57 PM
cron problem! blowtorch UNIX for Advanced & Expert Users 4 03-08-2006 01:12 AM
Problem with cron jhansrod AIX 2 11-25-2005 04:30 PM
cron problem VPN UNIX for Dummies Questions & Answers 2 04-16-2004 07:27 AM
Cron Problem Raiden Shell Programming and Scripting 4 11-16-2003 07:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-06-2006
chinnigd chinnigd is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 4
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
  #2 (permalink)  
Old 04-06-2006
d_swapneel14 d_swapneel14 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Mumbai,India
Posts: 57
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
  #3 (permalink)  
Old 04-06-2006
chinnigd chinnigd is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 4
I gave the complete path

Thanks for your reply.
I gave the complete path of the file but still it doesn't work
  #4 (permalink)  
Old 04-06-2006
chinnigd chinnigd is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 4
The problem is solved

instead of 'ping' alone

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

Thanks.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0