/* REXX */ /* PMwget 20 Jan. 2002 , Dallas E. Legan II in this case, PM does not stand for 'Presentation Manager' but "Poor Man's," this is a script to implement a "Poor Man's wget" for bootstrapping installation of wget, unzip, lynx, EMX and other tools that may be useful for simplifying installation of tools from the Internet It is based on some notes in REXX Tips and Tricks .inf file, that references back to IBM Technical Document # 17675356 where this information was originally documented. Likely targets: ftp://hobbes.nmsu.edu/pub/os2/util/archiver/uzs550x2.exe ftp://hobbes.nmsu.edu/pub/os2/apps/internet/mirror/wget181-os2-bin-vac.zip ftp://hobbes.nmsu.edu/pub/os2/dev/emx/v0.9d/emxrt.zip */ /* Data Definitions: */ /* Adjust these as needed: */ user = 'anonymous' ; password = 'leganii@surfree.com' ; /* A few constants: */ n = '0D0A'x ; envir = 'OS2ENVIRONMENT' ; currentdir = Directory() ; /* use the current directory for location */ PARSE VAR currentdir . '' . -1 lastchar ; IF '\' >< lastchar THEN currentdir = currentdir'\' ; PARSE SOURCE osystem method myself ; script = 'pmwget.scr' ; fqscript = currentdir || script ; /* end Data Definitions */ /* Assume a simple FTP URL, 'ftp://host/path/filename' */ /* PARSE ARG url See REXX Tips and Tricks: a '//' in the URL can 'eat' the rest of the command line, so some special measures are needed to get the URL from the command line. */ SELECT WHEN 'COMMAND' = method then DO CALL RxQueue CREATE, PMWGET ; CALL RxQueue SET, PMWGET ; /* '@cmd /c @echo %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 | rxqueue PMWGET' ; */ urlList = '' ; deltaurl = '' ; DO UNTIL Abbrev( deltaurl, 'ECHO', 4 ) /* 'ECHO is on.' */ urlList = urlList deltaurl ; '@shift' ; '@cmd /c @echo %0 | rxqueue PMWGET' ; PARSE PULL deltaurl END ; /* DO */ CALL RxQueue DELETE, PMWGET ; END ; /* WHEN */ OTHERWISE PARSE ARG urlList ; END ; /* select */ IF '' == urlList THEN DO SAY 'something is wrong with the URL list.' ; EXIT ; END PARSE UPPER VAR urlList . ' /Q ' +0 squiet , =1 . ' -Q ' +0 dquiet , =1 . ' /R ' +0 srename , =1 . ' -R ' +0 drename , =1 . ' /H ' +0 shelp , =1 . ' -H ' +0 dhelp ; /* -- not all implimented at this point */ quiet = '' << squiet | '' << dquiet ; rename = '' << srename | '' << drename ; help = '' << shelp | '' << dhelp ; IF help THEN DO SAY ''n, 'Usage: PMWGET [/h] ...'n, ' to automatically download the FTP URL files.'n, ''n RETURN ; END DO UNTIL '' = urlList PARSE VAR urlList url urlList ; PARSE VAR url 'ftp://' host '/' pathfile '->' newname ; IF '' == host THEN PARSE VAR url host '/' pathfile '->' newname ; IF '' == pathfile THEN DO SAY 'url='url'=' ; SAY 'Missing a path / filename' ; ITERATE ; END ; PARSE VAR host host ':' port ; spot = LastPos( '/', pathfile ) ; PARSE VAR pathfile fqpath =(spot) '/' simplefilename ; IF '' == fqpath THEN DO SAY 'fully qualified path ='fqpath'=' ; SAY 'Missing a fully qualified path' ; ITERATE ; END ; IF '' == simplefilname THEN DO SAY 'path / filename='pathfile'=' ; SAY 'Missing a filename' ; ITERATE ; END ; '@del 'script' 2> NUL' ; result = lineout( script, , 'machine 'host' login 'user' password 'password' macdef init'n, 'binary'n, 'hash'n, 'debug'n, 'status'n, 'cd 'fqpath''n, 'get 'simplefilename''n, 'bye'n ) ; result = Value( 'NETRC', fqscript, envir ) ; 'ftp -i 'host port ; '@del 'script' 2> NUL' ; newname = Strip( newname ) ; IF '' >< newname THEN 'move 'simplefilename' 'newname ; END ; /* processing of urllist */ RETURN ;