home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sun / misc / 5855 < prev    next >
Encoding:
Text File  |  1992-12-15  |  2.5 KB  |  84 lines

  1. Xref: sparky comp.sys.sun.misc:5855 alt.sources:2787
  2. Path: sparky!uunet!usc!sdd.hp.com!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!umn.edu!lynx!nmsu.edu!opus!emoreno
  3. From: emoreno@scheria.NMSU.Edu (Elena M. Castruita)
  4. Newsgroups: comp.sys.sun.misc,alt.sources
  5. Subject: Re: Automated FTP?
  6. Message-ID: <EMORENO.92Dec15101907@scheria.NMSU.Edu>
  7. Date: 15 Dec 92 17:19:07 GMT
  8. References: <1992Dec8.220145.5713@spang.Camosun.BC.CA>
  9.     <NICKEL.92Dec9200738@desaster.cs.tu-berlin.de>
  10.     <1g7shpINN9pa@atlpyr.ga.pyramid.com>
  11.     <1992Dec11.194130.14879@elroy.jpl.nasa.gov>
  12.     <1992Dec14.020745.15321@maths.tcd.ie>
  13. Sender: usenet@nmsu.edu
  14. Organization: New Mexico State University, Department of Computer Science
  15. Lines: 66
  16. In-Reply-To: tim@maths.tcd.ie's message of Mon, 14 Dec 1992 02:07:45 GMT
  17.  
  18.  
  19.  
  20. Try using the .netrc file a little more.  For example (using the
  21. previous example from tim@maths.tcd.ie (Timothy Murphy)):
  22. -----------------------------.netrc------------------------------------
  23. machine mac.archive.umich.edu login anonymous password tim@maths.tcd.ie
  24.  
  25. machine ftp.apple.com login anonymous password tim@maths.tcd.ie 
  26.     macdef init
  27.         cd mac/game/arcade
  28.         get bricklesplus2.0.sit.hqx
  29.         get brickwell.sit.hqx
  30.         quit
  31.  
  32.  
  33. --------------------------------------end----------------------------------
  34.  
  35.  
  36. When you ftp to ftp.apple.com, init ( the macro defined by macdef init )
  37. is automatically run.  No need for extra files.
  38.  
  39. Also, here is a little program to help ftp'ing...
  40.  
  41.  
  42. ___________________________________cut here________________________________
  43. #include <stdio.h>
  44. #define BUF_SIZE 255
  45. #define LINES    20
  46. main(){
  47.  
  48.     char a, line[LINES][BUF_SIZE];
  49.     int i,choice;
  50.     FILE *pipe;
  51.     char *home=(char *)getenv("HOME");
  52.     char *command1="grep machine ";
  53.     char *command2="/.netrc|cut -d\" \" -f2";
  54.     char command[BUF_SIZE];
  55.  
  56.     (void)strcat(command,command1);
  57.     (void)strcat(command,home);
  58.     (void)strcat(command,command2);
  59.     
  60.     if((pipe=popen(command, "r")) == NULL){
  61.         printf("Error opening pipe.\n");
  62.         exit(0);
  63.     }
  64.     
  65.     for(i=0;i < LINES && fgets(line[i],BUF_SIZE,pipe) != NULL;i++) {
  66.         line[i][strlen(line[i])-1]='\0';
  67.         printf("%2d...%s\n",i+1,line[i]);
  68.     }
  69.     do{
  70.         printf("\nEnter your choice: ");
  71.         scanf("%d",&choice);
  72.     }while ( choice - 1 < 0 || choice > i );
  73.  
  74.     execl("/usr/ucb/ftp","ftp","-i",line[choice-1],(char *)NULL);
  75. }
  76.  
  77.  
  78. ________________________________CUT HERE_________________________________
  79. --
  80.  
  81.            "I know what I want out of life.
  82.         I just don't know what I want to put into it."
  83.            Copyright @ 1991, Fitzgerald Enterprizes
  84.