homepage Welcome to WebmasterWorld Guest from 54.204.90.135
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Issues in executing shell script thru cron job
chanu




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

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

 

phranque




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

i would first check to make sure $PATH is correct for the cron job...

chanu




msg:3261443
 2:17 pm on Feb 23, 2007 (gmt 0)

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.

phranque




msg:3262201
 11:58 pm on Feb 23, 2007 (gmt 0)

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?

chanu




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

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

phranque




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

*.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"

chanu




msg:3272744
 4:50 pm on Mar 6, 2007 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved