*BSD News Article 43455


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msunews!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!gatech!purdue!news.bu.edu!dartvax.dartmouth.edu!coos!bradv
From: "Volker E. Bradley" <bradv@coos>
Newsgroups: comp.os.386bsd.questions
Subject: Re: Can you compile a small script for me?
Date: Thu, 16 Mar 1995 10:36:09 -0500
Organization: Dartmouth College, Hanover, NH, USA
Lines: 95
Message-ID: <Pine.ULT.3.91.950316102139.19949A-100000@coos>
References: <Pine.ULT.3.91.950316082035.15122A-100000@coos>
NNTP-Posting-Host: coos.dartmouth.edu
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <Pine.ULT.3.91.950316082035.15122A-100000@coos> 


My previous message contained 2 errors in the script. They have been 
corrected here.

                         /*zuke.c--program to save http addresses
             
                 copyright John Zureick 1/26/95
 
zuke is a utility I thought up to ease surfing the net.  What it does is 
take standard input, searches it for two strings:  http// and ftp//.  
Then it takes the address it finds and outputs it to a file in html 
format (I HOPE!) into a file specified earlier in the program-- change 
this to whatever name you like but keep the html extension or lynx will 
not recognize it!  

The best example to use this is using the trn newsreader.  Go into a 
newsgroup you are interested in.  Do a /http/a command.  This will select 
all articles with the string "http" in the text.  Then do a :zuke 
command.  This will run all those articles through the zuke program.  You 
will then have a page full of possibly interesting links!  After leaving 
trn, go into lynx and invoke it with the name of the file created by zuke.

                        */

#include <stdio.h>
#include <stdlib.h>

#define outfile "my.html"  /*put a valid file name on your system here
                           then invoke lynx with this file name*/
int main()
{
        FILE* stream;
        char c,inline[512],http[512],templine[512];
        int x;

        /* open file ly.dat*/
        stream = fopen(outfile,"a");
        if (stream == NULL)
            printf("Could not open output file\n"); 

        while (gets(inline)!=NULL)
        {
          /*find all occurrences of http addresses */
          if (strstr(inline,"http://")!=NULL)
          {
               x=strstr(inline,"http://");
               strcpy(http,x);

               /*let's isolate the http address*/
               for (x=0;http[x]!=' '&& http[x]!='\0';x++);
               http[x]='\0';
               /*the rest to these clear up a possible garbage character
                 at the end of the address: includes (.,;:>) */    
               if (http[x-1]=='.')
                  http[x-1]='\0';
               if (http[x-1]==',')
                  http[x-1]='\0';
               if (http[x-1]==';')
                  http[x-1]='\0';
               if (http[x-1]==':')
                  http[x-1]='\0';
               if (http[x-1]=='>')
                  http[x-1]='\0';
               fprintf(stream,"<LI><a href=\"%s\">%s</a>\n",http,http); 
          }

          /*find all occurences of ftp addresses */
          if (strstr(inline,"ftp://")!=NULL)
          { 
               x=strstr(inline,"ftp://");        
               strcpy(http,x);

               /*let's isolate the ftp address*/
               for (x=0;http[x]!=' '&& http[x]!='\0';x++);
              http[x]='\0';
              /*the rest of these clear up a possible garabage character
                at the end of the address: includes (.,;:>)*/
              if (http[x-1]=='.')
                 http[x-1]='\0';
              if (http[x-1]==',')
                 http[x-1]='\0';
              if (http[x-1]==';')
                 http[x-1]='\0';
              if (http[x-1]==':')
                 http[x-1]='\0';
              if (http[x-1]=='>')           
                 http[x-1]='\0';
              fprintf(stream,"<LI><a href=\"%s\">%s</a>\n",http,http); 
         }
       }

       fclose(stream);
       return(0);
}