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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cron issue kingdbag SUN Solaris 5 07-10-2008 08:14 AM
Another Cron issue. Beefy UNIX for Dummies Questions & Answers 2 03-13-2008 10:30 AM
FTP Cron Issue edua Shell Programming and Scripting 7 11-27-2007 12:30 AM
Issue with cron job nattynatty Shell Programming and Scripting 1 11-21-2005 04:37 PM
cron issue Optimus_P UNIX for Advanced & Expert Users 5 08-26-2002 10:30 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-26-2007
Registered User
 

Join Date: Jul 2007
Posts: 99
Issue with cron job -Please help

Hi ,

I have an issue with cron job that i have scheduled today. The problem is that when i run this script in command prompt it work good giving me the desired results but if i schedule this to run using cron job it failes giving a "syntax error in line 11 :$"..... Can anyone look into this and let me what to do.....Basically the script works to find a charater in the very first line of a records which is about 10000 lines and gives me an output if the charater is there or not. PLease ...please some one help me out

THis is the script that i am using:

FROM_DIR=/home/sandy_home/cc3; export FROM_DIR
LOG_DIR=/home/sandy_home/log_dir; export LOG_DIR

echo "NUMBER OF cc3 files BEFORE process STARTS-IF A FILE IS MISSING/NOT TRANSFERRED CONTACT Sandeep" > $LOG_DIR/che
ckfile.log

cd $FROM_DIR


ls -l *.cc3 >> $LOG_DIR/checkfile.log
for ccfile in $FROM_DIR/*.cc3

do
line=$(head -1 $ccfile)
if [[ $line = *ID* ]];
then
echo "----------------------------FOUND ID in $ccfile------------------------------" >> $LOG_DIR/checkfile.log
else
echo "---------------------------- ID NOT FOUND in $ccfile--------------------------" >> $LOG_DIR/checkfile.log

mv $ccfile /home/sandy_home/failed

echo "-----------The file that had no ID has been moved to failed directory---" >> $LOG_DIR/checkfile.log
fi;
done
Reply With Quote
Forum Sponsor
  #2  
Old 07-26-2007
jgt jgt is offline
Registered User
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 348
You should specify which shell you want your cron job to use.
It is likely running sh and your interactive shell is ksk or bash.
add
#!/bin/ksh
as the first line of your script.
Reply With Quote
  #3  
Old 07-26-2007
Registered User
 

Join Date: Jul 2007
Posts: 99
Thanks for the response. Actually i have not pasted that in this mail but i have that in the script but still this fails
Reply With Quote
  #4  
Old 07-27-2007
jgt jgt is offline
Registered User
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 348
Which is line eleven?
Reply With Quote
  #5  
Old 07-27-2007
Registered User
 

Join Date: Jul 2007
Posts: 99
line=$(head -1 $ccfile)
Reply With Quote
  #6  
Old 07-27-2007
jgt jgt is offline
Registered User
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 348
Try:
line=`head -1 $ccfile`
Reply With Quote
  #7  
Old 07-27-2007
Registered User
 

Join Date: Jul 2007
Posts: 99
Thanks for the help, I tried this and it worked:

strline=`head -1 $ccfile | cut -c1-10`
if [ "$strline" = "$sandeep_TXT" ]



and exported sandeep_TXT in in the script:

sandeep_TXT="ID"; export sandeep_TXT


Thanks again for ur help

Last edited by bsandeep_80; 07-27-2007 at 11:27 AM. Reason: change
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0