[SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop

From: Gaël Lams (lamsgael_at_gmail.com)
Date: 09/29/05

  • Next message: Ignatius Syofian: "[SLE] USB Mouse"
    Date: Thu, 29 Sep 2005 12:01:49 +0200
    To: suse-linux-e@suse.com
    
    

    Hi all,
     I'm trying to write a script that would connect via FTP to a list of hosts
    and download two files.
    I've the script working for one host and I'm trying to make it work with an
    array of IP.
     You will find the script below. When it runs it gives me a "syntax error:
    unexpected end of file" message for the last line (exit 0)
     If I comment all the FTP' stuff, it works (if we can say :-( and in the
    while loop I can echo all the variables (like element_count ....) but
    uncommenting the ftp lines breaks it.
     I've been googling without any success. I'm wondering whether it's possible
    to establish an FTP session in a loop or whether it should another way
    (which one) to do it?
     Thanks
     Gaël
     #!/bin/bash
    # here is my script

    declare -a IP
    # All subsequent commands in this script will treat
    # the variable "IP" as an array.

    # List of all the APC's IP
    IP[0]="xxx.xxx.xxx.xxx"

    # parameters common to all the APC UPS
    Directory="/"
    User="xxx"
    Password="xxx"

    element_count=${#IP[@]}
    # Special syntax to extract number of elements in array.

    index=0

    set -x
    # turn tracing on

    while [ "$index" -lt "$element_count" ]
    do

    ftp -n ${IP[$index]} <<End-Of-Session
    # -n option disables auto-logon

    user "$User" "$Password"
    cd $Directory
    get event.txt
    get data.txt
    bye
    End-Of-Session
    let "index = $index + 1"

    done

    set +x
    #turn tracing off

    exit 0


  • Next message: Ignatius Syofian: "[SLE] USB Mouse"

    Relevant Pages