home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
disdns.zip
/
disdns.cmd
Wrap
OS/2 REXX Batch file
|
1999-02-25
|
4KB
|
158 lines
/* program to convert netscape.hst to hosts file */
/* This code is far from optimized. Just did a quicky because after downloading a SHAREWARE
product that was to convert my bookmark.htm file it reached it's 'limit' while doing the conversion
and erased my HOSTS file. I only had only about a dozen entries for various machines that I have to
maintain, but to erase MY HOSTS file!!!! So screw it I figured, I'd write my own that could be free,
somewhat fast, could be set to run upon startup so it could continue to update my hosts file without
my having to do anything, and best of all just do the trick to speed up net access by bypassing DNS
servers. Anyway if you have read all of this, it is obvious you have less of a life than I.
If you have any suggestions, comments, or questions I can be reached at dodge@disisit.com
*/
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysloadFuncs'
call SysLoadFuncs
parse arg ext
IF ext='' THEN ext='\netscape.hst'
tmp=TRANSLATE(ext)
IF tmp='HELP' | tmp='-H' | tmp='/?' | tmp='-?' THEN DO
SAY 'Dynamic Information Systems'
SAY 'http://www.disisit.com'
SAY 'REXX rules and OS/2 is da bomb'
SAY '2/24/99 This program is FREE and I will be held harmless for any and all'
SAY 'damage that may occur for the proper use or misuse of this code.'
SAY 'disdns will search for all netscape.hst by default on current drive. '
SAY "disdns will convert all http://addresses to its' numeric address"
SAY "and populate your HOSTS file for speedier 'net access"
SAY 'Usage:'
SAY ' disdns [filename]'
SAY ' default is \netscape.hst'
SAY ' you may also use bookmark.htm files'
END
b=X2C(1A)
tab=X2C(09)
call SysFileTree ext, 'file', 'S'
flag=0
t=''
cr=D2C(13)
lf=D2C(10)
crlf=cr||lf
alpha_s=C2D('A')
alpha_e=C2D('Z')
num_s=C2D('0')
num_e=C2D('9')
Qfetch = rxqueue('create')
/* FIND HOSTS FILE */
'@set etc| rxqueue 'Qfetch
call rxqueue 'set', Qfetch
c=0
do while queued() \=0
pull t
PARSE VAR t '=' p
IF p='(Null)' THEN DO
SAY 'HOSTS directory not found you need to have a SET ETC=<drive>:\MPTN\ETC in your CONFIG.SYS file.'
EXIT
END
IF RIGHT(p,1)\='\' THEN p=p'\'
END
/* FIND USE_HOSTS_FIRST */
'@set USE_HOSTS_FIRST| rxqueue 'Qfetch
call rxqueue 'set', Qfetch
do while queued() \=0
pull t
PARSE VAR t '=' px
IF px='(Null)' THEN DO
SAY 'You need to have a SET USE_HOSTS_FIRST=1 in your CONFIG.SYS file.'
EXIT
END
END
/* READ IN HOSTS FILE NOT TO DUPLICATE ENTRY'S */
a.0=0
i=1
IF STREAM(p'hosts', 'c', 'query exists') \= '' THEN DO FOREVER
tmp=LINEIN(p'hosts')
IF tmp='' THEN LEAVE
tmp=TRANSLATE(tmp,' ',tab)
PARSE VAR tmp num ' ' a.i
a.i=TRANSLATE(a.i)
a.0=i
i=i+1
END
IF i>1 THEN CALL LINEOUT p'hosts'
do i=1 to file.0
parse var file.i . . size . name
name=STRIP(name)
say 'READING file 'name
tmp=CHARIN(name,1,size)
/* say 'length of tmp record .'LENGTH(tmp)'. .'size'.' */
IF LENGTH(tmp) \= size THEN DO
say 'Error opening 'name 'please close any applications that may be using this file'
LEAVE
END
DO WHILE POS('://',tmp) > 0
PARSE VAR tmp . '://' web '/' tmp
web=STRIP(web)
c_web=TRANSLATE(web)
/* say 'looking for 'c_web */
skip=0
DO x=LENGTH(c_web) to 1 BY -1
v=C2D(SUBSTR(c_web,x,1))
IF ((v >= alpha_s & v <= alpha_e) | (v >= num_s & v <= num_e) | v=C2D('.') | v=C2D('-') | v=C2D('_')) THEN
nop=nop
ELSE DO
skip=1
END
END
IF skip = 0 & LENGTH(c_web) > 2 THEN DO
IF a.0=0 THEN DO
a.1=c_web
a.0=1
END
DO x = 1 to a.0
IF c_web = a.x THEN DO
skip=1
END
END
IF skip=0 THEN DO
a.0=a.0+1
v=a.0
a.v=c_web
say web
'@nslookup 'web' | rxqueue 'Qfetch
call rxqueue 'set', Qfetch
c=0
do while queued() \=0
pull t
/* say t */
IF POS('ADDRESS',t) > 0 THEN DO
c=c+1
IF POS('ADDRESS:',t) > 0 THEN PARSE VAR t 'ADDRESS:' ip
IF POS('ADDRESSES:',t) > 0 THEN PARSE VAR t 'ADDRESSES:' ip ',' .
END
END
IF c=2 THEN DO
ip=STRIP(ip)
/* say 'ip ='ip */
IF ip \= web THEN Call LINEOUT p'hosts', ip||tab||web
END
END
END
END
END
say ' '
say 'Completed you should have speedier net access now!!'
say 'Dynamic Information Systems'
SAY 'http://www.disisit.com'
SAY 'REXX rules and OS/2 is da bomb'
RETURN 0