cron problem

Hi frnds...

I m facing very irritating problem already waisted my 2 days..

I have a following script..( i am pasting only the main code)

ftp -ivn 213.194.40.77 <<FTP
user $user $password
binary
cd $FileDir/out
lcd $localpath
get $file
rename $FileDir/out/$file $FileDir/tmp/$file
bye

FTP

if [ -f "$localpath/$file" ]
then
gzip -dcf $localpath/$file > $localpath/$TELEXISTable.dat
else
ErrorMessage="E2E - uploaded $TELEXISTable file $file is empty"
echo "$ToolName : $ErrorMessage"
fi

now the problem is.. when i execute this manually i got the expected .dat file ..
but when its executed by cron I got the .dat file of zero KB.

pl tell me what cud be the reason....
pl help

anchal

This is a bit of a guess but.........

Log in as the user you want to be when the script runs.
run crontab -e to get that user's own crontab
add the job to that crontab and see what happens. Obviously if you are already doing this then I am not helping very much here...

I am guessing that it *may* be a permissions thing.
Also consider doing the rename in the 'get' command in ftp.....
EG: get fname dir1/dir2/fname

thanks for the reply...
I am already using the same login for cron and running it from console.
what i mean to say is when I do "./script_name" from the console .. it gives me proper result.

also one more thing is that there is no problem with ftp.
coz i m already getting the .gz file on my local server.

I am assuming that the problem is with the command "gzip -dcf ......"

Please some 1 help me....
I stucked in great production issue coz of this :-((

what would be an example of $localpath/$file?

Is it a iwefioei.gz file? - I am assuming it is.

after running gzip -d on a ooi.gz file you should get ooi

I think it would be better to simply gzip -d your file and then mv it to the required filename and directory rather than redirecting the gzip output to your new location..

if [ -f "$localpath/$file" ]
then
# generate the filename without the .gz
export $fileunzipped = `echo $file | sed 's/.gz//'
#unzip the .gz file
gzip -dcf $localpath/$file
#move the unzipped file to the new location
mv $localpath/$fileunzipped $localpath/$TELEXISTable.dat
else
ErrorMessage="E2E - uploaded $TELEXISTable file $file is empty"
echo "$ToolName : $ErrorMessage"
fi

hope this helps

Hi

sorry about this but please note I have made a syntax error in one of the commands I have suggested. It should read as below...

export fileunzipped = `echo $file | sed 's/.gz//'`

browse the FAQs.
and pls don't start multiple threads on the same subject.

I take your point about looking at the faqs but I not too sure how I have created a multiple thread. I replied to a question and realised I had made a syntax error and so I corrected it. I am happy to be proved wrong but....

Hi ajcannon...

thanks for all your suggestions .. but the problem was still persists.. untill I did a very little change... I m still surprized why any1 including me and u cundn't remeber this..

so the soln comes here ... i just changed the gzip to the abolute path ie /usr/contrib/bin/gzip -dcf $localpath/$file > $localpath/$TELEXISTable.dat

now my old scripts too is working file... I already know its always a better way to use absolue path while dealing with crons... but.............i have to waste my 3 days ...
:slight_smile:

thnkas 2 all.