LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2019, 11:01 AM   #1
Shellscriptlnr
LQ Newbie
 
Registered: Mar 2019
Posts: 2

Rep: Reputation: Disabled
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)
 
Old 03-14-2019, 11:31 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,494
Blog Entries: 13

Rep: Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993
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:
  1. Tell people exactly what line 204 is, if not 1 line beyond the end of the script.
  2. Let us know what you have done to debug this.
  3. Please check the links in my signature referring to how to debug bash scripts, there are a great deal of hints in there which will help you to debug
  4. It seems as if you simply have a syntax error and didn't close a term such as an if-elif-fi, or a loop, or a case statement.
  5. I've never used it, but I've seen numerous recommendations to install and use shellcheck for checking your scripts. I will say that I have seen replies where the person did use it where they indicated it helped them greatly.
 
2 members found this post helpful.
Old 03-14-2019, 12:23 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,143

Rep: Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872
I believe you are missing a closing "fi" at line 121.
 
1 members found this post helpful.
Old 03-14-2019, 12:53 PM   #4
Shellscriptlnr
LQ Newbie
 
Registered: Mar 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank You for your Help. Closing "fi" resolved the issue.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line execution error: unexpected EOF while looking for matching `"' bash: -c: line 25: syntax error: unexpected end of file maheshreddy690 Linux - Newbie 1 12-25-2018 01:13 PM
PHP Parse error: syntax error, unexpected end of file in Command line code on line 1 pizzipie Programming 8 12-11-2014 12:49 PM
[SOLVED] Script returning with error "syntax error: unexpected end of file" n_raghuvanshi Linux - Software 4 08-25-2013 08:49 AM
Error in Bash: line 77: syntax error: unexpected end of file bribon Programming 8 07-13-2011 12:43 PM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration