#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    3
    Rep Power
    0

    FTP in a for or a while loop


    Hi

    I have a file abc.txt which has certain filenames

    abc.txt
    1.txt
    2.txt

    These files 1.txt and 2.txt are present in the same directory as abc.txt

    I want to ftp these files 1.txt and 2.txt reading abc.txt

    I have written a script with the following command.

    cat abc.txt | while read fname
    do

    ftp -in << EOF > $LOG_FILE
    verbose
    open ${SERVER}
    $LOGON
    binary
    cd $REMOTE_FILE_PATH
    put $fname
    close
    bye

    done

    However i am getting an error as
    Syntax error at line 50 : `do' is not matched.

    What could be the reason?

    Are there any other ways to acheive the same results what i am trying to do.

    Thanks much in advance
  2. #2
  3. Not a clue what to put ...
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2006
    Location
    in front of this keyboard
    Posts
    879
    Rep Power
    333
    Not sure if it will fix it, but you seem to have mislaid the line that says EOF (which will terminate your input)
    According to Sod's Law, buttered toast lands butter side down, when dropped.
    Per nature, cats always land on their feet.
    So, what happens when you strap buttered toast to the back of a cat and throw it out a window?
    .
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    FTP in a for or a while loop


    unix commands like loop mentioned here wont work when ftp is initiated.

    To resolve this - spool all the commands which you would like to do as part of FTP in a file and later give the file as input feed to FTP.

    thanks

    Regards,
    Madhan S.
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    834
    Rep Power
    387

    Cool


    Originally Posted by samit_9999
    Hi

    I have a file abc.txt which . . .
    . . .
    Are there any other ways to acheive the same results what i am trying to do.
    What madhan.subbiah suggests is this:
    Code:
    IFS=''
    FTPCMD=`awk '{print "put "$0;}' abc.txt`
    
    ftp -in << EOF > $LOG_FILE
    verbose
    open ${SERVER}
    user $LOGON
    binary
    cd $REMOTE_FILE_PATH
    $FTPCMD
    close
    bye
    EOF

    Comments on this post

    • DonR disagrees : What madhan.subbiah was doing is resurrecting a 7year old thread

IMN logo majestic logo threadwatch logo seochat tools logo