[ExtractStream] solution for no netcat not available

Josh Harding theamigo42 at y...
Wed, 6 Mar 2002 16:22:27 -0800 (PST)


--- Roger Merchberger <zmerch7@y...> wrote:

> Ah... okay, [I'm prolly not gunna put this quite right, but bear with
> me...] so a fifo is more like a 'standard stream' like STDIN, STDOUT,
> STDERR but linked to the filesystem instead of a filename linked to a
> 'standard stream' ...

That's a pretty good summary. They're also sometimes called named
pipes because it's similar to using pipes to feed stdout from one
command as stdin to the next, but being part of the file system, they
have names. Using 'em doesn't take any space, it just causes either
the reading or writing process to wait until the other is ready... when
both are ready, data flows. On some unix variants, you can make your
.plan a fifo and write a prog that sits in an infinite loop trying to
write to it. When someone fingers you, your process starts writing
(perhaps printing the current time as well as writting to a log file)
until you close the file and try to open it again.

Cat's fine to use to write to a fifo, just extraneous most of the
time... doesn't hurt tho. Only time you have problems with writing to
special files is when they don't exist... I've seen people run backups
on a system writing to /dev/rmt/5m when there was no /dev/rmt/5m. The
result being a new (huge) file in /dev/rmt called 5m and nothing on the
tape (which was at /dev/rmt/0m).

A very common thing that people do is begin a chain of pipes with cat,
e.g.:

cat myfile.txt | grep -i magicword
or
cat myfile.txt | more

both work fine without cat and more actually works better without cat
because it can seek backwards if you tell it the file rather than give
it a pipe:
grep -i magicword myfile.txt
and
more myfile.txt

You're fine to use as many extra cats as you want:
sendstream -s xxx xxx | cat | cat | cat | cat > /var/fifo

doesn't hurt, just extra.


=====
--The Amigo

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/