1838687 Members
6079 Online
110128 Solutions
New Discussion

.netrc

 
SOLVED
Go to solution
Dave La Mar
Honored Contributor

.netrc

At the risk of getting flamed -
I am working on a script that will allow the DBAs to send multiple files to multiple machines via ftp.
In my .netrc I haved coded 'if' statements for the login and password based on the hostname of the machine they wish to transfer a file. In doing so, though it works fine, an error appears for each 'elif' following the one that met the criteria. Since .netrc likes nothing below the mahine xxx login xxx password xxx line 'exit' even produces the error.
My intent is to reduce the harcoding within ftp scripts and allow one point of change for user or password.
In reading previous posts I have seen the login done within the script and wish to avoid this. I did not see any reference to multiple entries in the .netrc either.
Thanks for any input.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
2 REPLIES 2
Patrick Wallek
Honored Contributor
Solution

Re: .netrc

I am confused as to why you are using 'if' statements in the .netrc file. You can have multiple entries in the .netrc without doing anything fancy. All you do is put each entry on a separate line and ftp, when invoked, when pick up the appropriate entry from the .netrc.

For example:

machine name login uid passwd whatever
machine name1 login uid passwd whatever
machine name2.domain.com login uid2 passwd whatever2


Dave La Mar
Honored Contributor

Re: .netrc

Right you are.
Another case of missing the obvious by making something more complicated than need be.
Thanks for straightening me out.
dl
"I'm not dumb. I just have a command of thoroughly useless information."