Getting syntax error: unexpected end of file
Belwo is the script I am using and when I run it I am getting
line 204: syntax error: unexpected end of file. Below is the code I am using. Please help me resolving this issue. #!/bin/bash ############################################################################################## # # # NAME # # wf_file_xfer.prog # # # # PURPOSE # # This script will send files between the oracle app server and the Safe Trans # # file server. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ############################################################################################## ###################################################### # variables below are captured from the command line # ###################################################### # input variable below determines which type of files you are pushing files to safetransvalidate TRANSFER_TYPE=$5 echo "TRANSFER_TYPE" echo $TRANSFER_TYPE # input variable below for the user account used during remote transfers REMOTE_USER=$6 echo "REMOTE_USER" echo $REMOTE_USER echo "" # input variable below is the remote server's full hostname. REMOTE_ADDRESS=$7 echo "REMOTE_ADDRESS" echo $REMOTE_ADDRESS echo "" # input variable below is remote server's outbound folder REMOTE_FOLDER_OUTBOUND=${8} echo "REMOTE_FOLDER_OUTBOUND" echo $REMOTE_FOLDER_OUTBOUND echo "" # input variable below is the local server's outbound folder LOCAL_FOLDER_OUTBOUND=$9 echo "LOCAL_FOLDER_OUTBOUND" echo $LOCAL_FOLDER_OUTBOUND echo "" # input variable below is the path to the local archive folder for uploaded files LOCAL_FOLDER_ARCHIVES=${10} echo "LOCAL_FOLDER_ARCHIVES" echo $LOCAL_FOLDER_ARCHIVES echo "" # input variable below turns archiving off or on ARCHIVING=${11} echo "ARCHIVING" echo $ARCHIVING echo "" # input variable below is the email distriubtion list EMAIL_DISTRIBUTION_LIST=${12} echo "EMAIL_DISTRIBUTION_LIST" echo $EMAIL_DISTRIBUTION_LIST echo "" ###################################################### ################################################ # variables below are fixed and do not vary # ################################################ # variable below is the complete path for sftp SFTP_PATH=/usr/bin/sftp # variable below is for the status of transfers STATUS=0 # variable below is a place holder for sent files to determine if an email needs to be sent SENT_FILES="" # eval statements below are required to expand the variables # variable for the application to read them correctly eval LOCAL_FOLDER_OUTBOUND=$LOCAL_FOLDER_OUTBOUND eval LOCAL_FOLDER_ARCHIVES=$LOCAL_FOLDER_ARCHIVES echo "eval of LOCAL_FOLDER_OUTBOUND" echo $LOCAL_FOLDER_OUTBOUND echo "" echo "eval of LOCAL_FOLDER_ARCHIVES" echo $LOCAL_FOLDER_ARCHIVES echo "" echo Starting ############################################################### # Below verifies that we have input an accurate transfer mode # ############################################################### if [ "$TRANSFER_TYPE" != "wfpos" ]; then if [ "$TRANSFER_TYPE" != "wfach" ]; then echo "Program must be executed in format:" echo "wf_file_xfer.prog wfpos # to push positive pay files to safetransvalidate" echo "wf_file_xfer.prog wfach # to push ach files files from safetransvalidate" exit fi ##################################################################################### # Below pushes files to safetransvalidate if transfer mode wfpos is selected # ##################################################################################### if [ "$TRANSFER_TYPE" == "wfpos" ]; then echo "Transfer Type wfpos" for i in $LOCAL_FOLDER_OUTBOUND/ARPP_* do echo $i # $SFTP_PATH -v $REMOTE_USER@$REMOTE_ADDRESS <<< $"cd $REMOTE_FOLDER_INBOUND"$'\n'"put $i"$'\n'$'exit'$'\n' if [ $? != 0 ]; then STATUS=1 else CURRENT_FILE=${i#$LOCAL_FOLDER_OUTBOUND} CURRENT_FILE=${CURRENT_FILE#"/"} SENT_FILES=$SENT_FILES$'\n'$CURRENT_FILE fi if [ "$ARCHIVING" == "on" ]; then echo "Archiving is currently on" mv $i $LOCAL_FOLDER_ARCHIVES else echo "Archiving is currently off" fi done fi ##################################################################################### # Below pushes files to safetransvalidate if transfer mode wfach is selected # ##################################################################################### if [ "$TRANSFER_TYPE" == "wfach"]; then echo "Transfer Type wfach" for i in $LOCAL_FOLDER_OUTBOUND/ACH* do echo $i # $SFTP_PATH -v $REMOTE_USER@$REMOTE_ADDRESS <<< $"cd $REMOTE_FOLDER_INBOUND"$'\n'"put $i"$'\n'$'exit'$'\n' if [ $? != 0 ]; then STATUS=1 else CURRENT_FILE=${i#$LOCAL_FOLDER_OUTBOUND} CURRENT_FILE=${CURRENT_FILE#"/"} SENT_FILES=$SENT_FILES$'\n'$CURRENT_FILE fi if [ "$ARCHIVING" == "on" ]; then echo "Archiving is currently on" mv $i $LOCAL_FOLDER_ARCHIVES else echo "Archiving is currently off" fi done fi ########################################################################## # Below sends email to selected users with the list of files transmitted # # If there is no email it sends nothing # ########################################################################## echo "Sent Files" echo $SENT_FILES if [ $SENT_FILES == "" ]; then echo "no files to send" else echo "The files sent to bank are listed below"$'\n'"$SENT_FILES" fi echo Complete ####################################################################### # Below exits with status 1 if there was a problem or status 0 if not # ####################################################################### echo "STATUS" echo $STATUS if [ $STATUS != 0 ]; then exit 1 else exit 0 fi ~ ~ ~ (END) |
Welcome to LQ.
Please review how to use [code] tags to enclose code so that it retains the formatting properly. What would help, would be two or more things:
|
I believe you are missing a closing "fi" at line 121.
|
Thank You for your Help. Closing "fi" resolved the issue.
|
I am still getting couple of errors.Please help me resolve the errors.
Errors: wf_file_xfer.prog: line 150: [: missing `]' wf_file_xfer.prog: line 179: [: ==: unary operator expected Below is the script I am using. #!/bin/bash ############################################################################################## # # # NAME # # wf_file_xfer.prog # # # # PURPOSE # # This script will send files between the oracle app server and the Safe Trans # # file server. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ############################################################################################## ###################################################### # variables below are captured from the command line # ###################################################### # input variable below determines which type of files you are pushing files to safetransvalidate TRANSFER_TYPE=$5 echo "TRANSFER_TYPE" echo $TRANSFER_TYPE # input variable below for the user account used during remote transfers REMOTE_USER=$6 echo "REMOTE_USER" echo $REMOTE_USER echo "" # input variable below is the remote server's full hostname. REMOTE_ADDRESS=$7 echo "REMOTE_ADDRESS" echo $REMOTE_ADDRESS echo "" # input variable below is remote server's outbound folder REMOTE_FOLDER_OUTBOUND=${8} echo "REMOTE_FOLDER_OUTBOUND" echo $REMOTE_FOLDER_OUTBOUND echo "" # input variable below is the local server's outbound folder LOCAL_FOLDER_OUTBOUND=$9 echo "LOCAL_FOLDER_OUTBOUND" echo $LOCAL_FOLDER_OUTBOUND echo "" # input variable below is the path to the local archive folder for uploaded files LOCAL_FOLDER_ARCHIVES=${10} echo "LOCAL_FOLDER_ARCHIVES" echo $LOCAL_FOLDER_ARCHIVES echo "" # input variable below turns archiving off or on ARCHIVING=${11} echo "ARCHIVING" echo $ARCHIVING echo "" # input variable below is the email distriubtion list EMAIL_DISTRIBUTION_LIST=${12} echo "EMAIL_DISTRIBUTION_LIST" echo $EMAIL_DISTRIBUTION_LIST echo "" ###################################################### ################################################ # variables below are fixed and do not vary # ################################################ # variable below is the complete path for sftp SFTP_PATH=/usr/bin/sftp # variable below is for the status of transfers STATUS=0 # variable below is a place holder for sent files to determine if an email needs to be sent SENT_FILES="" # eval statements below are required to expand the variables # variable for the application to read them correctly eval LOCAL_FOLDER_OUTBOUND=$LOCAL_FOLDER_OUTBOUND eval LOCAL_FOLDER_ARCHIVES=$LOCAL_FOLDER_ARCHIVES echo "eval of LOCAL_FOLDER_OUTBOUND" echo $LOCAL_FOLDER_OUTBOUND echo "" echo "eval of LOCAL_FOLDER_ARCHIVES" echo $LOCAL_FOLDER_ARCHIVES echo "" echo Starting ############################################################### # Below verifies that we have input an accurate transfer mode # ############################################################### if [ "$TRANSFER_TYPE" != "wfpos" ]; then if [ "$TRANSFER_TYPE" != "wfach" ]; then echo "Program must be executed in format:" echo "wf_file_xfer.prog wfpos # to push positive pay files to safetransvalidate" echo "wf_file_xfer.prog wfach # to push ach files files from safetransvalidate" exit fi fi ##################################################################################### # Below pushes files to safetransvalidate if transfer mode wfpos is selected # ##################################################################################### if [ "$TRANSFER_TYPE" == "wfpos" ]; then echo "Transfer Type wfpos" for i in $LOCAL_FOLDER_OUTBOUND/ARPP* do echo $i # $SFTP_PATH -v $REMOTE_USER@$REMOTE_ADDRESS <<< $"cd $REMOTE_FOLDER_INBOUND"$'\n'"put $i"$'\n'$'exit'$'\n' if [ $? != 0 ]; then STATUS=1 else CURRENT_FILE=${i#$LOCAL_FOLDER_OUTBOUND} CURRENT_FILE=${CURRENT_FILE#"/"} SENT_FILES=$SENT_FILES$'\n'$CURRENT_FILE fi if [ "$ARCHIVING" == "on" ]; then echo "Archiving is currently on" mv $i $LOCAL_FOLDER_ARCHIVES else echo "Archiving is currently off" fi done fi ##################################################################################### # Below pushes files to safetransvalidate if transfer mode wfach is selected # ##################################################################################### if [ "$TRANSFER_TYPE" == "wfach"]; then echo "Transfer Type wfach" for i in $LOCAL_FOLDER_OUTBOUND/ACH* do echo $i # $SFTP_PATH -v $REMOTE_USER@$REMOTE_ADDRESS <<< $"cd $REMOTE_FOLDER_INBOUND"$'\n'"put $i"$'\n'$'exit'$'\n' if [ $? != 0 ]; then STATUS=1 else CURRENT_FILE=${i#$LOCAL_FOLDER_OUTBOUND} CURRENT_FILE=${CURRENT_FILE#"/"} SENT_FILES=$SENT_FILES$'\n'$CURRENT_FILE fi if [ "$ARCHIVING" == "on" ]; then echo "Archiving is currently on" mv $i $LOCAL_FOLDER_ARCHIVES else echo "Archiving is currently off" fi done fi ########################################################################## # Below sends email to selected users with the list of files transmitted # # If there is no email it sends nothing # ########################################################################## echo "Sent Files" echo $SENT_FILES if [ $SENT_FILES == "" ]; then echo "no files to send" else echo "The files sent to bank are listed below"$'\n'"$SENT_FILES" # echo "The files sent to bank are listed below"$'\n'"$SENT_FILES" | /usr/bin/mailx -r TBD -s "Files sent to bank" $EMAIL_DISTRIBUTION_LIST fi echo Complete ####################################################################### # Below exits with status 1 if there was a problem or status 0 if not # ####################################################################### echo "STATUS" echo $STATUS if [ $STATUS != 0 ]; then exit 1 else exit 0 fi |
you've already been asked to put CODE tags around your code.
please do this for all the code in this thread; as you can see it breaks the page's layout. could you also
|
I was able to fix the errors. Thank You
|
Line 150: The closing "]" is a separate argument to the "[" command and needs a space preceding it.
Line 179: If $SENT_FILES is null, then this line expands as Code:
if [ == "" ]; then |
Quote:
don't hit and run. and i would really appreciate if you could fix the formatting. thanks. |
All times are GMT -5. The time now is 06:31 PM. |