I'm writing a script which needs to run under an 'automation' account and there is already a .netrc machine definition for the server I need to connect to.
If I create a new machine entry in the .netrc with a different account this will, of course, be ignored and the ftp session will connect to the incorrect account. Also, I don't have access to perl's Net::Ftp.
Knowing the source O/S would help. Anyway, Perl excluded, SFTP exclude, and talking in general about most unixes
FTP client looks for ${HOME}/.netrc
After login has completed the environment variable $HOME does not have to refer to a real home directory. In your script, you can change and export $HOME prior to starting ftp. Thus you can have as many .netrc files as you so desire in directories of your choice. Each file should still have permissions 600 and be owned by root or the specific ftp user.
Another approach is to have multiple names for the same FTP server IP address in /etc/hosts , and then to refer to each name in the common .netrc file .