Urgent: Script.sh: syntax error at line 72: `PROGRESS=$' unexpected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent: Script.sh: syntax error at line 72: `PROGRESS=$' unexpected
# 1  
Old 05-04-2009
Data Urgent: Script.sh: syntax error at line 72: `PROGRESS=$' unexpected

I have written a shell script to Automatically FTP a file. The script runs fine when doing it manually but when I schedule it using a crontab it gives me an error.

Code:
.
.
.
echo "-----------------Starting File FTP---------------------" >> $PROS_LOAD_LOG
echo "open X.XX.XX.XXX"  >> $PROS_LOAD_LOG 
echo "user uname pass" >> $PROS_LOAD_LOG
echo "put $FILENAME" >> $PROS_LOAD_LOG 
echo "close" >> $PROS_LOAD_LOG
PROGRESS=$(/bin/ftp -vin < $PROS_LOAD_LOG 2>&1)
echo $PROGRESS >> $PROS_LOAD_LOG

echo "--------------------Check for Errors-------------------">> $PROS_LOAD_LOG

if [[ `echo $PROGRESS | grep "No such file or directory"` != "" ]]
then
.
.
.
fi

Error: Script.sh: syntax error at line 72: `PROGRESS=$' unexpected

Please reply asap. I have been breaking my head since last two weeks.

Thanks
Joy
# 2  
Old 05-04-2009
Hi
Did you assigned correctly a value to the variable $PROS_LOAD_LOG?
If yes, check that you have sufficient privilege to access it.

Cheers
# 3  
Old 05-04-2009
Error

Thanks for the reply.

The value for $PROS_LOAD_LOG is defined correctly. I added the below line to provide correct priveleges but still the same error.

Code:
 
chmod 777 $PROS_LOAD_LOG

# 4  
Old 05-04-2009
Which SHELL are you using? Can you try to run the standalone command with the right files and logs

Code:
PROGRESS=$(/bin/ftp -vin < $PROS_LOAD_LOG 2>&1)

I believe the problem is coming from this expression substitution.


cheers,
Devaraj Takhellambam
# 5  
Old 05-04-2009
I am using bash. I executed the script directly and it works fine. It does the ftp and PROGRESS has the details of the FTP process. But only when I run it using a crontab it errors out.
# 6  
Old 05-05-2009
The default shell for jobs in cron is "sh".
Does your first line specify "bash" ?

Something like:

Code:
#!/usr/bin/bash

# 7  
Old 05-05-2009
Yes It does...

The Full Script is below. Appologise for not posting it earlier.

Code:
# !/bin/bash
#Global Variables
HOME=XXX
CONNECT_STRING=XXX
LOCATION=$HOME
FILENAME=file.txt
SQLUSR=XXX
SQLPASS=XXX
ARCHIVE=XXX/Archive
PROS_LOAD_LOG=XXX/IDM_LOG_`date +%Y%m%d%H%M%S`.txt
ARCHIVE_PROS_LOAD_LOG=XXX/Archive/IDM_LOG_`date +%Y%m%d%H%M%S`.txt
SUFFIX=`date +%y%m%d`
 
#Setting Oracle Global vars - starts
ORACLE_HOME=/XX/oracle/product/9.2.0
PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export ORACLE_HOME PATH LD_LIBRARY_PATH PROS_LOAD_LOG FILENAME
#Setting Oracle Global vars - ends
echo "=====================================================">> $PROS_LOAD_LOG
echo "---------------Starting Script-----------------------">> $PROS_LOAD_LOG
chmod 777 $PROS_LOAD_LOG
echo "START TIME:" >> $PROS_LOAD_LOG
date >> $PROS_LOAD_LOG
echo "=====================================================">> $PROS_LOAD_LOG
echo "-------------Started File Generation-----------------">> $PROS_LOAD_LOG
sqlplus $SQLUSR/$SQLPASS@$CONNECT_STRING @/IDM_Auto_SQL.sql >> $PROS_LOAD_LOG
echo "------------File Generation Completed-----------------">> $PROS_LOAD_LOG
echo "======================================================">> $PROS_LOAD_LOG
echo "">> $PROS_LOAD_LOG
echo "======================================================">> $PROS_LOAD_LOG
echo "-------Checking if the file has been generated--------" >> $PROS_LOAD_LOG
if [ -r file.txt]
        then
 echo "--------------File Generated Successfully-------------" >> $PROS_LOAD_LOG
 SOURCE_FILE_SIZE=`ls -l $FILENAME|tr -s " "|cut -d" " -f5`
 echo "----------------Checking for file size----------------" >> $PROS_LOAD_LOG
 echo "The File Size: $SOURCE_FILE_SIZE" >> $PROS_LOAD_LOG 
 if [ $SOURCE_FILE_SIZE != 0 ]
  then
  echo "--------------File Size greater than 0KB---------------" >> $PROS_LOAD_LOG
  echo "=======================================================" >> $PROS_LOAD_LOG
  echo "" >> $PROS_LOAD_LOG
  echo "=======================================================" >> $PROS_LOAD_LOG
  echo "------------------Calling FTP Script-------------------" >> $PROS_LOAD_LOG
  
    
echo "" >> $PROS_LOAD_LOG
echo "=======================================================" >> $PROS_LOAD_LOG
echo "------------------Inside FTP Script--------------------" >> $PROS_LOAD_LOG
echo "-----------------Starting File FTP---------------------" >> $PROS_LOAD_LOG
echo "open X.XX.XXX.XX"  >> $PROS_LOAD_LOG 
echo "user uname pass" >> $PROS_LOAD_LOG
echo "put $FILENAME" >> $PROS_LOAD_LOG 
echo "bye" >> $PROS_LOAD_LOG

PROGRESS=$(/bin/ftp -vin < $PROS_LOAD_LOG 2>&1)

echo $PROGRESS >> $PROS_LOAD_LOG
echo "--------------------Check for Errors-------------------">> $PROS_LOAD_LOG
if [[ `echo $PROGRESS | grep "No such file or directory"` != "" ]]
then
 echo "" >> $PROS_LOAD_LOG
 echo "=======================================================" >> $PROS_LOAD_LOG
 echo "-----------Initiating Failure Mail Sequence------------" >> $PROS_LOAD_LOG
 (
 echo "*** THIS IS AN AUTOMATED EMAIL, PLEASE DO NOT REPLY. ***"
 echo ""
 echo "Hi,"
 echo ""
 echo "The Process Failed to FTP the File."
 echo ""
 echo "Thank you,"
 echo ""
 echo "*** THIS IS AN AUTOMATED EMAIL, PLEASE DO NOT REPLY. ***"
 uuencode $PROS_LOAD_LOG LogFile.txt
 ) | mailx -s "Process - Failed" -r +xx@xx.com 'xxx@xx.com'
 exit
else
 echo "---------------------No Errors Found-------------------">> $PROS_LOAD_LOG
fi
fi
fi


Last edited by tanhajoy; 05-05-2009 at 10:27 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

2. Shell Programming and Scripting

Syntax error at line 24: `(' unexpected

Hi, I am getting an wired error.... the script is running fine when i run it manually... but the same when i try to run in nohup mode, i am getting error if Error: syntax error at line 24: `(' unexpected The above if is the 24th line!!! I dont understand the error... (4 Replies)
Discussion started by: Nithz
4 Replies

3. Shell Programming and Scripting

Syntax error at line 14: `gw_user=' unexpected

Masters, i iam writing a script (dont have much experience in the process of learning) which handles file copy to multiple servers and users for deployment purpose. Below is the snippet. When ever i run i get syntax error but it works fine on another machine. Please help me out. if then... (10 Replies)
Discussion started by: ameyrk
10 Replies

4. Shell Programming and Scripting

Urgent:- syntax error near unexpected token `done'

hi, i need to with making while loop logic working in shell program, i got syntax error the following Code and Error details: x=60 while do /usr/bin/php /home/egrdemo/public_html/pposh_new/cron-set.php x=$((x-1)) sleep 1 done ... (5 Replies)
Discussion started by: kannankrp
5 Replies

5. UNIX for Dummies Questions & Answers

syntax error at line 8: `(' unexpected

Hi I am having a shell script load_data.sh which calls /home/users/project/.profile. When am executing the script, am getting below error: $sh -x bin/load_data.sh null + . /home/users/project/.profile bin/load_data.sh: syntax error at line 8: `(' unexpected The line which is throwing... (1 Reply)
Discussion started by: brijesh.dixit
1 Replies

6. Shell Programming and Scripting

Help on shell script : syntax error at line 62: `end of file' unexpected

Hi All, I have written a korn script (code pasted below). It is giving the error while debugging "new.sh: syntax error at line 62: `end of file' unexpected". I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
Discussion started by: schandrakar1
7 Replies

7. Shell Programming and Scripting

syntax error at line 28: `(' unexpected

hi can anyone pls look into this....shell script... Pls find the error below: > sh -n tmp tmp: syntax error at line 28: `(' unexpected isql -Usa -S$1 -P`grep $1 dbpassword|cut -d ":" -f3` -w2000 -b<<! set nocount on declare @i int declare @dbname char(6) declare @tmp int if... (10 Replies)
Discussion started by: rajashekar.y
10 Replies

8. UNIX Desktop Questions & Answers

line 3: syntax error near unexpected token `('

Hi All I've used UNIX in the past experimenting with commands through terminal but thats about it. Im now currently teaching myself "C". Using a book from the library, the first chapter asks you run and compile your program from a command-line prompt. As you will see the program is very simple,... (4 Replies)
Discussion started by: camzio
4 Replies

9. UNIX for Dummies Questions & Answers

syntax error at line 33: `elif` unexpected

#!/bin/sh echo "Choose option: e, d, l, t, p, or x." read option if test $option = e then echo "Filename?" read file if test ! -f $file then echo "No such file" else echo "Yes its a file" fi ... (4 Replies)
Discussion started by: hazy
4 Replies

10. Programming

sh: syntax error at line 1: `>' unexpected

I compiled C program under SUN OS sparcv9 ...I had a problem related to SIGBUS which has been resolved by adding an option to the CC compiler which is memory alignement option ..-memalign=1i as I remmber ...after running the program I got the below error please let me KNow more details what should... (2 Replies)
Discussion started by: atiato
2 Replies
Login or Register to Ask a Question