Find the answer to your Linux question:
Results 1 to 2 of 2
Hey Bash-Scripters, maybe you can help me...? I've been trying to make automated ftp bash scripts, but somehow i can't figure out how it works... First i've tried to create ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    3

    Automated FTP...?

    Hey Bash-Scripters, maybe you can help me...?
    I've been trying to make automated ftp bash scripts, but somehow i can't figure out how it works...

    First i've tried to create an script, that opens a ftp connection:

    Code:
    #!/bin/bash -xv
    HOSTNAME="192.168.178.20"
    USERNAME="media"
    PASSWORD="media"
    ftp -n -v $HOSTNAME
    ascii
    user $USERNAME $PASSWORD
    get movie5.avi
    bye
    When i execute this script it stops after the command
    Code:
    ftp -n -v $HOSTNAME
    it is waiting for further input.

    When I extend the line that makes script stop with <<EOT It will work
    Code:
    ftp -n -v $HOSTNAME <<EOT
    <- that works!!!


    I do not understand what the <<EOT is making (EOF is also functioning) Why?

    Then I've tried to test the script inside an if statement
    Code:
    #!/bin/bash -xv
    
    HOSTNAME="192.168.178.20"
    USERNAME="media"
    PASSWORD="media"
    
    if [ -e "movie5.avi" ]; then
    	echo "movie is here, do not download"
    	else
    		ftp -n -v $HOSTNAME << EOT
    		ascii
    		user $USERNAME $PASSWORD
    		get movie5.avi
    		bye
    fi
    This code returns the error:
    here-document at line 10 delimited by end-of-file (wanted `EOT')
    when I remove the "EOT", the script is stopping than before.

    I don't understand why it does not work, I hope u can help me!!!

    All the best

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    Google/Forum Search > bash ftp script

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...