Posted by peter on November 18, 2011
Sometimes you need a scripts to automatically ftp to a server that requires a user name and password. Here is how to do it.
Create a file called ".netrc" in your home directory (the user who will run the script). Put the following in the file:
machine ftp.serveryouneedtoconnectto.com login yourloginname password yourpassword
Edit the above to suit.
Make sure permissions on the .netrc are correct for the user and that the user has a valid logon on the remote ftp server.
NB Make sure .netrc file is rw for the owner and no access for everyone else. This is for security reasons. To change permissions type the following:
chmod 600 ~/.netrc