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