[comp.sys.ibm.pc.rt] Using the .netrc file for ftp'ing from wsmr-simtel20.army.mil

compton@cpsvax.cps.msu.edu (Compton David L. ACT F89) (03/30/90)

	For those of you using Suns running Unix System V, there is an
easy way to request simtel20 files.  Putting a .netrc file in your
download directory (.) of the form:

--------Start-----------------
machine wsmr-simtel20.army.mil
login anonymous
password compton@cpsin3.cps.msu.edu
macdef init
tenex
cd PD1:<MSDOS.MSWINDOWS>       
get WNQVT415.ARC 
bye


-------End-------------------

will cause ftp to run the macro init which executes the script:
tenex; cd ....; get.....; bye;

In this case, there are exactly two carriage returns following the
'bye'.  Moreover, this has made file transfers much more reliable since
I defined an alias: alias fsim 'ftp wsmr-simtel20.army.mil' so that
fsim &   runs the file transfer in the background so that using ps you
can look to see whether it has hung (fairly often).  Obviously, if you
are informed that there are --too many anonymous users-- you will have
to kill the process to terminate.  Anyway, using the simtel35.exe
program to select files and using the (F3)Include, (F4)Generate
combination produces a file of the format:

-d PD1:<MSDOS.MSWINDOWS>
-t      WNQVT415.ARC

which is not suitable for pasting into your .netrc

I wrote a short filter in 'C' to do the conversion:


#include <stdio.h>
#define LONG_STR 40
main()
{
	char r_buf[LONG_STR],s_buf[LONG_STR],h_buf[3];
	*s_buf='\0';    /* s_buf[0] */
	while(scanf("%s%s",h_buf,r_buf) != EOF)
	  switch(h_buf[1]) {
		case 'd':
			if(strcmp(r_buf,s_buf)) {
				printf("cd %s\n",r_buf);
				strcpy(s_buf,r_buf);
			}
			break;
		case 't':
			printf("get %s\n",r_buf);
			break;
	  }
}

The filter converts to the correct format so that the output can be
pasted into the .netrc

It makes ftp'ing from simtel20 very easy (almost too easy :) 

The simtel35.exe is available on simtel20.  

Please excuse the trivial nature of this article, but I thought it might
help some of those who have trouble ftp'ing.  Running ftp using the
.netrc file fails less often than using ftp interactively (Empirical).

David Compton@cpsvax.cps.msu.edu