In a message dated 10-02-99, John Clarke said to Eddy Thilleman about
"hstart wget?"
Hi John,
ET> I asked this in the wget mailing list, it is possible if you use a
ET> program 'tee' in addition:
JC>I'd appreciate a copy of 'tee' attached to my email address
JC>below if you can organise it.
Since this is the OS2REXX echo, we can write our own!
================================= TEE.CMD ==================================
/* REXX version of the TEE command */
PARSE ARG Arg_list
Append_flag = TRANSLATE(WORD(Arg_list,1))
/* Remove the /A flag if supplied */
IF Append_flag == '/A' THEN
DO
Arg_list = STRIP(SUBSTR(Arg_list,3),'L')
Append_flag = 'APPEND'
END
ELSE
Append_flag = 'REPLACE'
/* Make sure at least 1 file was specified */
IF LENGTH(Arg_list) = 0 THEN EXIT 12
File_name = .ARRAY~NEW(1)
/* Parse the filenames into an array of strings */
p = VERIFY(Arg_list,' ')
DO i = 1 BY 1 WHILE p += 0
IF SUBSTR(Arg_list,p,1) == "'" | SUBSTR(Arg_list,p,1) == '"' THEN
DO
q = VERIFY(Arg_list,SUBSTR(Arg_list,p,1),'M',p+1)
p = p + 1
DO WHILE SUBSTR(Arg_list,q,1) == SUBSTR(Arg_list,q+1,1)
q = VERIFY(Arg_list,SUBSTR(Arg_list,p,1),'M',q+2)
END
END
ELSE
q = VERIFY(Arg_list,' ','M',p+1)
IF q = 0 THEN q = LENGTH(Arg_list) + 1
File_name[i] = SUBSTR(Arg_list,p,q-p+1)
p = VERIFY(Arg_list,' ','N',q+1)
END
/* Open a corresponding array of stream objects */
File_stream = .ARRAY~NEW(File_name~ITEMS())
DO i = 1 TO File_name~ITEMS()
File_stream[i] = .STREAM~NEW(File_name[i])~~OPEN('WRITE '||Append_flag)
END
DROP File_name
/* Open standard devices */
Stdin = .STREAM~NEW('STDIN:')~~OPEN('READ')
Stdout = .STREAM~NEW('STDOUT:')~~OPEN('WRITE')
/* Copy the lines across */
DO WHILE Stdin~STATE() == 'READY'
Line_buff = Stdin~LINEIN()
DO Output_file OVER File_stream
Output_file~LINEOUT(Line_buff)
END
Stdout~LINEOUT(Line_buff)
END
DROP Output_file
/* Close all the files */
DO i = File_stream~FIRST() TO File_stream~LAST()
File_stream[i]~CLOSE()
END
Stdin~CLOSE()
Stdout~CLOSE()
EXIT 0
============================================================================
As is my usual practice in this echo, I typed this code directly into my QWK
reader, so it is totally untested. Note that it is in Object REXX.
Regards
Dave
___
* MR/2 2.25 #353 * Microsoft Windows: Proof that P.T. Barnum was correct.
--- Maximus/2 3.01
45
* Origin: Air Applewood, OS/2 Gateway to Essex 44-1279-792300 (2:257/609)
|