The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem In Shell Script satyakide Shell Programming and Scripting 11 09-24-2007 07:00 AM
Problem with SU or SSH in shell script sravanp UNIX for Dummies Questions & Answers 2 01-24-2006 08:00 AM
Shell Script problem bnohifi Shell Programming and Scripting 1 07-06-2005 11:02 PM
Problem with shell script zylwyz Shell Programming and Scripting 2 06-29-2005 10:01 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2006
Registered User
 

Join Date: May 2006
Posts: 4
Help! Problem with Shell Script.

hi! i have the script which i hit error. anyone knows whats wrong? i have been trying for the last 3 days and don't seems to be able to find an answer.

the error i got was sp_out.sh[34]: syntax error at line 51 : `<<' unmatched. However when i move the FTP portion of the script out of the If condition, it works. The script as follows.


Quote:
#!/bin/ksh

# Singpost Automated Script - Out Script (eStudent to Singpost)
#
# To login into Singpost Internet Server to deposit the daily
# oustanding balance list genereated from eStudent.
#
# FTP the files from eStudent App Server to Singpost
# production directory: /opt2/saprd/sa76/saobjects/sf/sam
#

SERVERHOST=XXX.XXX.XXX.X

# eStudent Path
#ESTUDENT_PATH=/opt2/saprd/sa76/saobjects/sf/sam
#ESTUDENT_BACKUP_PATH=/opt2/saprd/sa76/saobjects/sf/sam/backup
ESTUDENT_PATH=/opt2/sadvl/orasadvl/sa76/saobjects/sf/sam
ESTUDENT_BACKUP_PATH=/opt2/sadvl/orasadvl/sa76/saobjects/sf/sam/backup

YYYY_DATE=$(date +%Y)
JULIAN_DATE=`expr $(date +%j) - 1`
ESTUDENT_FILENAME="ITEBAT1_ITL0100.${JULIAN_DATE}"
SINGPOST_FILENAME="ITL0100.${JULIAN_DATE}"
LOG_FILENAME="${ESTUDENT_PATH}/sp_log/sp_out_ftp_${YYYY_DATE}${JULIAN_DATE}.log"

cd $ESTUDENT_PATH

echo "Singpost FTP Script - $(date)" > "${LOG_FILENAME}"
echo "UPLOAD/PUT $SINGPOST_FILENAME" >> "${LOG_FILENAME}"

if [ ! -f "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" ]
then
echo "ERROR! Outgoing file not found ${ESTUDENT_PATH}/${ESTUDENT_FILENAME}." >> "${LOG_FILENAME}"
else
if [ ! -d "${ESTUDENT_PATH}/sp_out_archive" ]
then
echo "ERROR! Directory ${ESTUDENT_PATH}/sp_out_archive missing." >> "${LOG_FILENAME}"
else
echo "Create backup copy ${ESTUDENT_PATH}/sp_out_archive/${ESTUDENT_FILENAME}." >> "${LOG_FILENAME}"
cp "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" "${ESTUDENT_PATH}/sp_out_archive/${ESTUDENT_FILENAME}"

echo "Rename filename ${ESTUDENT_FILENAME} to ${ESTUDENT_PATH}/${SINGPOST_FILENAME}." >> "${LOG_FILENAME}"
mv -f "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" "${ESTUDENT_PATH}/${SINGPOST_FILENAME}"

ACCT=TEST;export ACCT
PASS=TEST123;export PASS

echo "Trying to connect to machine ${SERVERHOST}" >> "${LOG_FILENAME}"
# run FTP and create a FTP log file

ftp -nv $SERVERHOST >> "${LOG_FILENAME}" <<-EOF
user $ACCT $PASS
ascii
put "${ESTUDENT_PATH}/$SINGPOST_FILENAME"
bye
EOF
rm "${ESTUDENT_PATH}/$SINGPOST_FILENAME"
fi
fi
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-23-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 371
Hi , did you try:

Code:
ftp -nv $SERVERHOST <<-EOF >> "${LOG_FILENAME}"
Reply With Quote
  #3 (permalink)  
Old 05-23-2006
Registered User
 

Join Date: May 2006
Posts: 4
tried that but still dun work
Reply With Quote
  #4 (permalink)  
Old 05-23-2006
Registered User
 

Join Date: Feb 2006
Location: California
Posts: 45
It should work.. try this
Code:
ftp -nv $SERVERHOST >> "${LOG_FILENAME}" <<EOF
user $ACCT $PASS
ascii
put "${ESTUDENT_PATH}/$SINGPOST_FILENAME" 
bye 
EOF
Reply With Quote
  #5 (permalink)  
Old 05-23-2006
Registered User
 

Join Date: May 2006
Posts: 4
nope...it still dun work...same error message...

could it be something wrong with my if-else-fi statements?
Reply With Quote
  #6 (permalink)  
Old 05-24-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 371
Try this:
Code:
!/bin/ksh

# Singpost Automated Script - Out Script (eStudent to Singpost)
#
# To login into Singpost Internet Server to deposit the daily
# oustanding balance list genereated from eStudent.
#
# FTP the files from eStudent App Server to Singpost
# production directory: /opt2/saprd/sa76/saobjects/sf/sam
#

SERVERHOST=XXX.XXX.XXX.X

# eStudent Path
#ESTUDENT_PATH=/opt2/saprd/sa76/saobjects/sf/sam
#ESTUDENT_BACKUP_PATH=/opt2/saprd/sa76/saobjects/sf/sam/backup
ESTUDENT_PATH=/opt2/sadvl/orasadvl/sa76/saobjects/sf/sam
ESTUDENT_BACKUP_PATH=/opt2/sadvl/orasadvl/sa76/saobjects/sf/sam/backup

YYYY_DATE=$(date +%Y)
JULIAN_DATE=`expr $(date +%j) - 1`
ESTUDENT_FILENAME="ITEBAT1_ITL0100.${JULIAN_DATE}"
SINGPOST_FILENAME="ITL0100.${JULIAN_DATE}"
LOG_FILENAME="${ESTUDENT_PATH}/sp_log/sp_out_ftp_${YYYY_DATE}${JULIAN_DATE}.log"

cd $ESTUDENT_PATH

echo "Singpost FTP Script - $(date)" > "${LOG_FILENAME}"
echo "UPLOAD/PUT $SINGPOST_FILENAME" >> "${LOG_FILENAME}"

if [ ! -f "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" ]
then
echo "ERROR! Outgoing file not found ${ESTUDENT_PATH}/${ESTUDENT_FILENAME}." >> "${LOG_FILENAME}"
else
if [ ! -d "${ESTUDENT_PATH}/sp_out_archive" ]
then
echo "ERROR! Directory ${ESTUDENT_PATH}/sp_out_archive missing." >> "${LOG_FILENAME}"
else
echo "Create backup copy ${ESTUDENT_PATH}/sp_out_archive/${ESTUDENT_FILENAME}." >> "${LOG_FILENAME}"
cp "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" "${ESTUDENT_PATH}/sp_out_archive/${ESTUDENT_FILENAME}"

echo "Rename filename ${ESTUDENT_FILENAME} to ${ESTUDENT_PATH}/${SINGPOST_FILENAME}." >> "${LOG_FILENAME}"
mv -f "${ESTUDENT_PATH}/${ESTUDENT_FILENAME}" "${ESTUDENT_PATH}/${SINGPOST_FILENAME}"

ACCT=TEST;export ACCT
PASS=TEST123;export PASS

echo "Trying to connect to machine ${SERVERHOST}" >> "${LOG_FILENAME}"
# run FTP and create a FTP log file
{ #Subshell here
ftp -nv $SERVERHOST >> "${LOG_FILENAME}" <<-EOF
user $ACCT $PASS
ascii
put "${ESTUDENT_PATH}/$SINGPOST_FILENAME"
bye
EOF
}
rm "${ESTUDENT_PATH}/$SINGPOST_FILENAME"
fi
fi
Reply With Quote
  #7 (permalink)  
Old 05-25-2006
Registered User
 

Join Date: May 2006
Posts: 4
Any chance you have white space left of EOF?

When you move the ftp section into the "if" do you have any indenting? <<- will strip leading tabs only, not spaces. Better to have EOF always at the left edge.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0