Hi All,
I have a script which is running fine while triggered manually, However if I placed
in crontab it throwing an error.
#!/usr/bin/ksh
set -vx
lc=1
st_date=$(`date "+%Y%m%d"`)
LOGFILE=/home/transfer.log.$st_date
file="/home/OM_WF.log.$st_date"
Manual run -
lc=1
+ lc=1
st_date=$(date "+%Y%m%d")
+ + date +%Y%m%d
st_date=20130606
LOGFILE=/home/transfer.log.$st_date
+ LOGFILE=/home/transfer.log.20130606
file="/home/OM_WF.log.$st_date"
+ file=/home/OM_WF.log.20130606
Cron run -
lc=1
lc=1
st_date=$(d./OM_ftp_transfer.sh: syntax error at line 8: `st_date=$' unexpected
Thanks in advance
Is that your full script? Error says line 8 and your code is in line 4.
1 Like
Full code
####################################################################################
# This script will check the OM_WF.log file existence and if exist transfer
# the dummy flow.dat file to zwg38ser.
#######################################################################################
#!/usr/bin/ksh
set -vx
lc=1
st_date=$(date "+%Y%m%d")
LOGFILE=/home/transfer.log.$st_date
file="/home/OM_WF.log.$st_date"
if [ -f "$file" ]
then
echo "$file found.Transfering low.dat dummy file at $(date)" >> $LOGFILE
cd /home/
echo "File created" >> $LOGFILE
touch flow.dat
chmod 777 flow.dat
echo "FTP Process Started" >> $LOGFILE
cp /home/infa_shared/OM_WORKFLOW.netrc $HOME/.netrc
chmod 700 $HOME/.netrc
ftp zwg38ser.comm.com
rm $HOME/.netrc
echo "FTP Process Completed" >> $LOGFILE
rm om_workflow.dat
echo "File flow.dat deleted" >> $LOGFILE
exit
else
while [[ $lc -ne 15 ]]; do
sleep 60
let lc=lc+1
print "Waiting for low.dat file for $lc minutes at $(date)" >> $LOGFILE
if [ -f "$file" ]
then
echo "$file found.Transfering low.dat dummy file at $(date)" >> $LOGFILE
cd /home/
echo "File created" >> $LOGFILE
touch flow.dat
chmod 777 flow.dat
echo "FTP Process Started" >> $LOGFILE
cp /home/infa_shared/OM_WORKFLOW.netrc $HOME/.netrc
chmod 700 $HOME/.netrc
ftp zwg38ser.comm.com
rm $HOME/.netrc
echo "FTP Process Completed" >> $LOGFILE
rm om_workflow.dat
echo "File flow.dat deleted" >> $LOGFILE
exit
fi
done
fi
Jotne
4
You should use only parentheses or back tics, not both
st_date=$(`date "+%Y%m%d"`)
Best
st_date=$(date "+%Y%m%d")
ok
st_date=`date "+%Y%m%d"`
Edit: I now see that its ok in the full script.
1 Like
Hi All,
The issue happened due hashbang(#!) not defined at first line, now i modified and placed in first line. Its working in cron
Thanks.
1 Like