simple BASH question about ftp transfer.

Discussion in 'Software' started by Robster12, Sep 15, 2004.

  1. Robster12

    Robster12 The Horse Whisperer

    I wanted to automate an ftp transfer to my isp. I googled and found this:
    http://www.linuxgazette.com/book/print/6140
    which is just what I needed. So, I have my ~/.netrc , and I write the script:



    Code:
    #!/bin/bash
    echo This will use a "here" document to embed ftp commands in this script
    # Beginning of "here" document
    ftp <<**
    open ftp.eskimo.com
    cd public_html/Images
    delete bigpicture.jpg
    put bigpicture.jpg
    delete newmembers.jpg
    put newmembers.jpg
    delete thirdwave.jpg
    put thirdwave.jpg
    delete fourthwave.jpg
    put fourthwave.jpg
    quit
    **
    #end of "here" document
    echo ftp transfer ended.
    Now, this thing worked. I know it did, because I later downloaded the files with Firefox browser.

    The question is... why was the output to the screen so strange?
    Here it is:

    Code:
    robstr12@darkstar:~/Folding_Graphics$ ls
    bigpicture.jpg  fourthwave.jpg  newmembers.jpg  thirdwave.jpg
    robstr12@darkstar:~/Folding_Graphics$ ~/Shell_Scripts/ftp_maker.sh
    This will use a here document to embed ftp commands in this script
    bigpicture.jpg: No such file or directory.
    newmembers.jpg: No such file or directory.
    thirdwave.jpg: No such file or directory.
    fourthwave.jpg: No such file or directory.
    ftp transfer ended.
    robstr12@darkstar:~/Folding_Graphics$
    It looks like it was complaining that there was "No such file or directory"
    I will get to learning this soon, but, I thought that if someone was really up on BASH, it would be nothing for them to answer this.
    :)
     
  2. Wookie

    Wookie Sergeant Major

    not sure why it does that, do you have SSH access? If so you can write a script using rm and such.
     
  3. Robster12

    Robster12 The Horse Whisperer

    I'm not worried about security. I know that having the ~/.netrc file on the harddrive is not secure, since it contains the password unencrypted.

    This is not a problem, it is just a curiousity to me. I'm sure as I practice more scripting it will come to me. :)

    BTW: I'm just happy to have the thing work at all! :)
     
  4. GregoryDalton

    GregoryDalton Private E-2

    Hmmm I guess if you wanted you could modularise it a bit so you can check return codes. Such as having a bash script that receives a parameter and gets taht parameter from the server.

    But redirect the output of each ftp attempt to /dev/null as you invoke it, or at the very least redirect standard error to /dev/null may get rid of the strange messages. Im not sure where they are coming from.

    Cheers,
    Greg
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds