Welcome to WebmasterWorld Guest from 50.16.112.199

Forum Moderators: bakedjake

Issues in executing shell script thru cron job

   
1:27 pm on Feb 23, 2007 (gmt 0)

5+ Year Member



Guyz,

I am facing problem in executing a shell script thru cron job.If I execute it from putty window it getting executed.

Here is my script:

#! /bin/sh
PATH=$PATH:/usr/sfw/bin
#Copy all the text file to the icb\upd\out folder on the ICB PC in Dublin
#This is performed via SAMBA file copy
smbclient \\\\192.168.56.14\\gex\$ -U conficb%Welcome01 -c "cd \icb\upd\out\; prompt off; mput *.txt"

Here is my crontab entry configured to execute daily at 12:30 PM:

30 12 * * * /ecomm/iplanet/nes60/smbcopy.sh >> /ecomm/iplanet/nes60/trace.log

The job is getting triggered properly.This I know as I can see the time stamp of trace.log as 12:30 daily updated.

Can you please advise me on this?

Thanks,C

1:52 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



i would first check to make sure $PATH is correct for the cron job...
2:17 pm on Feb 23, 2007 (gmt 0)

5+ Year Member



Thanks phranque. Infact I had put echo $PATH in my code and this is the output that comes up when cron job executes.
/usr/bin::/usr/sfw/bin
and I made sure that smbclient that I am using is available in /usr/sfw/bin.
11:58 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



next i would check ownership and permissions.
"whoami" for the cron job and the owner/permission settings of the executable and directories being accessed.

are you getting an actual error message or just nothing happens?

4:14 pm on Mar 2, 2007 (gmt 0)

5+ Year Member



I have checked the file permissions as well. everything seems to be fine. I have redirected the output and errors to a text file and here is the error message that I get in the log

*.txt: No such file or directory

Actually in my code I have used the following statement:

smbclient \\\\192.168.56.14\\gex\$ -U conficb%Welcome01 -c "cd \icb\upd\out\; prompt off; mput *.txt"

The task of this is to transfer all text files available in this directory to another server. I think it is searching for a file with a name *.txt instead of considering all files with txt extension.

My question here is how to make Unix understand that its the pattern here. But when i directly run the shell script on command prompt it considers it in the right way. Not sure why this behavior when its executed thru cron job. Please help me..

2:52 am on Mar 3, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



*.txt: No such file or directory

Actually in my code I have used the following statement:

smbclient \\\\192.168.56.14\\gex\$ -U conficb%Welcome01 -c "cd \icb\upd\out\; prompt off; mput *.txt"


is that error coming from the shell script or from smbclient?
the double quotes should escape the wildcard character from the shell script, so it should not be trying to expand *.txt in the script.
if the message is coming from smbclient, make sure you have the cron job set the directory to what ever directory you want to send *.txt from.
you can do this either in the shell with a cd command or i assume you can do it in smbclient with lcd.
this would be the directory you were in when you "directly run the shell script on command prompt".

smbclient \\\\192.168.56.14\\gex\$ -U conficb%Welcome01 -c "lcd (local_path); cd \icb\upd\out\; prompt off; mput *.txt"
4:50 pm on Mar 6, 2007 (gmt 0)

5+ Year Member



Thanks a ton phranque! Your solution worked :-). Actually going to local directory in the script worked.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month