lavv17 / lftp

sophisticated command line file transfer program (ftp, http, sftp, fish, torrent)
http://lftp.yar.ru
GNU General Public License v3.0
1.08k stars 159 forks source link

Enhancement Request - Add option to specify .netrc location #640

Open SenseiC opened 2 years ago

SenseiC commented 2 years ago

If you have large numbers of FTP drop boxes you have to interact with (unique data location for every customer case), having the ability to pass the location of the .netrc file would make life much easier. From the lftp file netrc.cc beginning at line 43:

`NetRC::Entry *NetRC::LookupHost(const char *h,const char *u)
{
   char str[256];
   char chost[256]="";
   char cuser[256]="";
   char cpass[256]="";
   char cacct[256]="";

   const char *const home=getenv("HOME");
   if(!home)
      return 0;

   const char *const netrc=xstring::cat(home,"/.netrc",NULL);
   FILE *f=fopen(netrc,"r");`

Therefore lftp only looks in the user's "home" directory (if it exists) for a .netrc file.

For example this option exists in Curl. From the Curl man page:

   --netrc-file <filename>
          This option is similar to -n, --netrc, except that you
          provide the path (absolute or relative) to the netrc file
          that curl should use.  You can only specify one netrc file
          per invocation. If several --netrc-file options are
          provided, the last one will be used.

          It will abide by --netrc-optional if specified.

          This option overrides -n, --netrc. Added in 7.21.5.