the magic of netrc

If you're like me, you probably use ftp every day but have never read the man page. I wish I had though, because it reveals the netrc(5) file for automating logins, and even simple macros.

    login ianw
    password password
    macdef upload
           cd /public_html/a/dir
           lcd /var/www/a/dir
           mput blah.txt

machine ...

Actually, I only found out about this because the Python ftplib code mentions it. So you can do something like

from ftplib import FTP
from netrc import netrc

(username,account,password) = netrc().authenticators('')

ftp = FTP('')
ftp.login(username, password)

It's always nifty re-discovering something that has been around since the dawn of time_t!