Interactive ftp get/put


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interactive ftp get/put
# 1  
Old 05-18-2009
Interactive ftp get/put

Hi All,

I'm trying to get this to work but when I execute it I get the following error

./ftp_upload.sh: line 78: syntax error: unexpected end of file.

This was working before I expanded the script and had the here document part directly below within a function.

Can anyone spot what I've done wrong.

Cheers,

Darren.

Code:
       lftp $Server $Portnum <<End-Of-Session
"$1" "$filename"
bye
End-Of-Session



Code:
#!/bin/bash
######################################################################
#                               Validation
######################################################################
E_ARGERROR=85
if [ -z "$2" ]
then
echo "Usage: `basename $0` Filename-to-upload"
exit $E_ARGERROR
fi ###################################################################### # Defaults ###################################################################### Server=${Server:-10.77.40.237} Portnum=${PortNum:-21} ###################################################################### # Functions ###################################################################### #~~~Manually enter paramaters, export or set in this file ftp_interactive #to false to prevent this ftp_interactive=${ftp_interactive:-true} function confirm() { if [ "$ftp_interactive" == "true" ]; then
eval confirm_contents=\$$1
read -p "Confirm value for \$$1 [$confirm_contents] "
confirm_input
if [ "$confirm_input" != "" ]; then
eval $1="\"$confirm_input\""
fi
fi } function options(){
echo "Valid options for this are:"
for i in $*
do
echo " [$i]"
done
} function execution(){
lftp $Server $Portnum <<End-Of-Session
"$1" "$filename"
bye
End-Of-Session
} ###################################################################### # Execution ###################################################################### echo "Please enter a valid ftp servers IP address" options 10.77.40.237 confirm Server echo "Enter your ftp servers port number" options 21 confirm Portnum filename=$2 if [ "$1" == "get" ]; then
execution get
else
execution put
fi exit 0


Last edited by darrenm; 05-18-2009 at 08:01 AM.. Reason: indenting text
# 2  
Old 05-18-2009
Please use indentation in your code and place the code within code tags, this is almost unreadable.

Have you saved the file with a windows editor?
# 3  
Old 05-18-2009
Quote:
Originally Posted by Franklin52
Please use indentation in your code and place the code within code tags, this is almost unreadable.
Done sorry about that

Quote:
Originally Posted by Franklin52
Have you saved the file with a windows editor?
Nope, all done via nano
# 4  
Old 05-18-2009
Remove the spaces before the closing delimiting identifier of the here document in this function:

Code:
function execution(){

    lftp $Server $Portnum <<End-Of-Session

    "$1" "$filename"

    bye

End-Of-Session
}

# 5  
Old 05-18-2009
Quote:
Originally Posted by Franklin52
Remove the spaces before the closing delimiting identifier of the here document in this function:
Damn forgot you couldn't do that with a here document. Thank you very much Smilie
# 6  
Old 05-18-2009
Code:
     << [-]word
           The shell input is read up to a line that is the  same
           as word, or to an EOF. No parameter substitution, com-
           mand substitution, or file  name  generation  is  per-
           formed  on  word.  The  resulting  document,  called a
           here-document, becomes  the  standard  input.  If  any
           character  of  word  is  quoted,  no interpretation is
           placed upon the characters of the document. Otherwise,
           parameter  and command substitution occur, \NEWLINE is
           ignored, and \ must be used to quote the characters \,
           $,  `,  and  the  first  character  of  word.  If - is
           appended to <<, then all  leading  tabs  are  stripped
           from word and from the document.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to see the status of all the ftp put & get files logs and curent ftp transfer status ?

How to see the status of all the ftp put & get files logs and curent ftp transfer status if any active ftp running in the background ? (2 Replies)
Discussion started by: i4ismail
2 Replies

2. Shell Programming and Scripting

Hebrew character convert error while put thru ftp

Hi all , i have a script which cp xml files from linux to other server thru ftp my xml file contains charcters in hebrew . my script is #!/bin/bash HOST="....." USER="....." PASSWORD="..." cd /usr2/app/naama/ filelist='find . -mmin -60 | tail -n +2 | awk -F "/" '{print $2}' | grep xml'... (3 Replies)
Discussion started by: naamas03
3 Replies

3. Shell Programming and Scripting

Non-interactive FTP within SSH session not working

Hello everyone! I am trying to log-in to a remote server over SSH, transfer file1 there, perform some checks, capture the results in file2 and transfer file2 back to my local server - all of this non-interactively. Initially, I tried to do this within a singe SSH session, using the following... (2 Replies)
Discussion started by: Subu1987
2 Replies

4. Shell Programming and Scripting

Status of FTP Put command

Can i capture the status of put command after i ftp a file? (4 Replies)
Discussion started by: aixjadoo
4 Replies

5. UNIX for Dummies Questions & Answers

FTP put command problem

Hello,I am trying to put something on the ftp server using the put command. Whenever I try, I get this error: ftp> put SIMS.war local: SIMS.war remote: SIMS.war 200 PORT command successful 553 Can't open that file: Permission denied I have set rwx for all on that file and I still am... (3 Replies)
Discussion started by: mojoman
3 Replies

6. HP-UX

Ftp cannot put file larger than 64kb

Hi gurus, I have a problem with ftp access. The first 2 test e.g. Test A & Test B was successful with the file size 64kb (800++ numbers). The third test with file size 120kb was failed. The error is "Netout :Connection reset by peer". No password entered manually since the test run from the... (3 Replies)
Discussion started by: yeazas
3 Replies

7. Shell Programming and Scripting

how to put file from one ftp to another ftp location

hi, I have one file located in ftp.I want to place that file in different ftp location. Up to now i am doing it manually using get command and copying that file in to my local system and then putting that file in different ftp using put command. now i want to automate that using shell... (1 Reply)
Discussion started by: prasee
1 Replies

8. Shell Programming and Scripting

put an interactive script in background after taking input

i am trying to find a way to put an interactive script in the background after taking input from the user a few test lines i was trying: date echo "Enter location" LOCATION= read LOCATION sleep 100 sleep 200 date for this small example i want the script to as the user for the... (7 Replies)
Discussion started by: epsilonaurigae
7 Replies

9. UNIX for Advanced & Expert Users

Put fails during FTP

Hi All, I am facing a while i use mput to the server. Actually i have data on client machine which is windows XP. The data is near to 1GB. I have zipped the data. I can ftp and connect to Server(Which has Fedora 4 running). but when i do mput *.zip it gives an error. I tried to put in a... (2 Replies)
Discussion started by: prakash.kudreka
2 Replies

10. Solaris

script to performm interactive ftp

hi, i have to generate a script, which performs FTP action. The script should handle both put and get functions. can anybody help me on hw to develop the script (1 Reply)
Discussion started by: prash_b
1 Replies
Login or Register to Ask a Question