From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 15-AUG-1989 02:21
To:	MRGATE::"ARISIA::EVERHART"
Subj:	UNSHAR for the SHAR files

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Mon, 14 AUG 89 22:44:57 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Mon, 14 Aug 89 22:23:25 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA16812; Mon, 14 Aug 89 22:11:11 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 15 Aug 89 04:35:53 GMT
From: unmvax!nmtsun!warner%twg.com@ucbvax.Berkeley.EDU  (M. Warner Losh)
Organization: New Mexico Tech Hydrology Program
Subject: UNSHAR for the SHAR files
Message-Id: <3073@nmtsun.nmt.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


I posted this a long time ago, but it looks like people missed it, so
here it comes again.  This is a DCL program to extract shared files.  If
you  save the parts of a multi-part posting, in order, this guy eliminates
the edit the resulting file step.  It eats all lines up to the first one
that starts with a '$'.  It eats that one as well, copies the rest of the
file into  a tmp file and executes it.  I know it works with older version
of SHARE, but I haven't tried it on the very latest release.  It assumes
that the neat feature of VMS_SHARE that was present around version 6 that
allowed you to have headers and trailers of a message between the parts
has not gone away.  To run it, just do @unshar file-name.  It only has one
sneaky dcl trick.  There is a file that is opened from dcl (called X) that
is copied from the current point to the end of the file via copy x foo.
I think the comments are still intact....


$! UNSHAR.COM(X-1) MWL, see end of file for more details
$	Verify = 'F$Verify (0)
!$	ON	ERROR -
!	THEN	GOTO CleanUp
$	In_Name	= F$SEARCH (P1)
$	IF	In_Name .NES. "" -
	THEN	GOTO Have_Input_File
$ Get_In_Name_Loop:
$	READ	SYS$COMMAND In_Name/PROMPT="_File to unshar$ "
$	IF	F$SEARCH(In_Name) .EQS. "" -
	THEN	GOTO Get_In_Name_Loop
$ Have_Input_File:
$	OPEN/READ	in	'In_Name'
$ Top_Of_Loop:
$	READ/END=No_Shar_Found	in line
$	IF	F$EXTRACT (0, 2, Line) .NES. "$!" -
	THEN	GOTO Top_Of_Loop
$	PID = F$GetJPI (0, "PID")
$	COPY	In Tmp_'PID'.COM	! Copies the rest of P1 into tmp.com
$	CLOSE IN
$	SET NOVERIFY
$	@TMP_'PID'.COM
$	DELETE TMP_'PID'.COM;*
$	GOTO Get_Me_Out_Of_Here
$ CleanUp:
$	CLOSE/NOLOG In
$	IF	F$SEARCH ("TMP_''PID'.COM") .NES. "" -
	THEN	DELETE TMP_'PID'.COM;*
$	GOTO	Get_Me_Out_Of_Here
$ No_Shar_Found:
$	WRITE SYS$OUTPUT "I Couldn't find anything that looks like a shar file"
$ Get_Me_Out_Of_Here:
$	Verify = F$VERIFY(Verify)
$	EXIT
!
!	U N S H A R . C O M
!
!	Program		: Unshar
!	Version		: X-1
!	Version date	: 22-Jan-1989
!	Programmer	: M. Warner Losh (warner@hydrovax.nmt.edu)
!	Abstract	: Unshars
!
!		D e s c r i p t i o n
!
!	Takes a shar message, strips out all lines until it sees one beginning
!	with a "$", then executes the rest of the file.  For use in multi-
!	part postings, do the following:
!		o save all message in some order (eg xxx.01, xxx.02, etc)
!		o copy all messages into one file (eg copy xxx.%% xxx.src)
!		o run unshar on it (eg @unshar xxx.src)
!
! Sleezy DCL tricks:
!      When DCL has a file open, you can refer to that stream using the
!	logical that you specified on the open command.  So if you read
!	the first five records from the file, then the logical that you
!	used refers to the rest of the file.  For example:
!
!		$ open xxx junk.com
!		$ read xxx line
!		$ read xxx line
!		$ read xxx line
!		$ read xxx line
!		$ read xxx line
!		$ copy xxx tmp.com
!		$ close xxx
!
!	will all but the first five records in junk.com to tmp.com.
!

--
Warner Losh
warner@twg.com
What happened to our innocence, did it go out of style?
My spelling and views are my own.  Only the letters have been changed...

