unshar business

Brad Turner mbt at bridge2.3Com.Com
Fri Dec 9 01:50:22 AEST 1988


In article <12273 at cup.portal.com> John_-_DeBert at cup.portal.com writes:
>In article [283 at gsg.UUCP] Cathy Segedy writes:
>
>>write (and test to my own satisfaction) a simple C program to do it instead.
>>      [stuff deleted]
>>This took considerably less time than reading the huge volume of news that
>>has been generated on the subject.
>>
>>					Cathy Segedy

Being really lazy I did the same thing about a year ago only I used lex and
a shell script.
This ain't a contest, but below is a sufficiently short lex program to
chop off the headers of map files as they are sent out.

----------------cut here-------guillotin.l------------------
%START A B
%%
	{BEGIN A;}
<A>[^\000]		{}
<A>"if "		{BEGIN B; printf("%s",yytext);}
<A>"export "		{BEGIN B; printf("%s",yytext);}
<A>"sed "		{BEGIN B; printf("%s",yytext);}
<A>"cat "		{BEGIN B; printf("%s",yytext);}
<A>"echo "		{BEGIN B; printf("%s",yytext);}
<B>[^\000]		{printf("%s",yytext);}
%%
----------------cut here------------------------------------
All that this little lex program does is throw away all input until
it sees a word it recognizes. It then goes into state B and simply
transcribes stdin to stdout (hence the name guillotin, it chops off
headers :-) 

I set up cron to wake up every night, go to the usenet maps directory,
assert a uucp lock to keep uuxqt from running while I do. For each
file in the directory run it through "cat $file | guillotin | sh"
mv the output to my real maps directory and rm the usenet map file.
After this I run pathailas on the contents of my real maps dir.

It was pretty simple and I managed to do it in an afternoon. I'm
guess-tamating I spent as much time "re-inventing" a package as I
would have spent hunting it down and installing/understanding it.

-brad-
-- 
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
Brad Turner	1330 Ashleybrook Ln.	(919) 768-2097	| I speak for myself
3Com Corp.	Winston-Salem, NC 27103 mbt at bridge2	| NOT for my employer.



More information about the Comp.unix.wizards mailing list