Using non-interactive FTP

We have a secret (therefore, widely known and very popular) stash of films and TV series episodes somewhere in the office. This clandestine repository is an FTP server, which probably gets more traffic than the various issue tracking and CRM systems we use around here.

Sometimes, though, it gets tedious logging on to the server, checking for new additions, before finding out what new files to download. Good thing the pirates were sane enough to come up with a "What's new" page in the root of the FTP server's public directory. So, I whipped up a very simple script that would fetch this file:


#!/bin/sh
ftp pirate.ftp < user username password
get whatsnew.txt
quit
EOT


I placed the above in a crontab, executed daily at early dawn. Then, it's just a matter of grepping for my faves and downloading them promptly. The download could be automated as well, but it's a bit tedious and requires more braincells than I can dedicate for this sort of work -- much easier to just eyeballing what files I particularly like from the text file.

Comments

  1. lol...necessity really is the mother of invention! Nice work!

    ReplyDelete
  2. if the ftp server is using auto login, you must specify '-n' in your script.
    ftp ftpsite.ftp
    becomes
    ftp -n ftpsite.ftp

    thanks for the tip.

    ReplyDelete
  3. Yup, '-n' will suppress autologin. Good catch. Thanks.

    ReplyDelete

Post a Comment

Popular posts from this blog

Pull files off Android phone