Re: How do you ...

From: Adam McKee <amckee_at_no.spam.please>
Date: Tue Jul 27 1999 - 12:46:54 CST

If the parts are: p1, p2, ... pn, then:

        % cat p1 p2 ... pn > blah.uue
        % uudecode blah.uue > blah

or in a single step:

        % cat p1 p2 ... pn | uudecode > blah

play-by-play:

1. 'cat' writes each input file to stdout (in the order they are given on
   the command line)
2. cat's standard output is a pipe -- the other end of which is uudecode's
   standard input
3. uudecode does its magical uudecoding mumbo-jumbo, writes decoded output
   on its standard output, which happens to be a file called 'blah'

The beauty of this is that neither 'cat' nor 'uudecode' needed to do
anything special to accommodate this usage. All 'cat' knows is that it
writes to standard output -- it doesn't know what stdout is (e.g. pipe,
disk file, or tty) and it doesn't *want* to know. Likewise, uudecode
doesn't care what its stdin is. When you use pipes and i/o redirection
like this, it's entirely the *shell's* responsibility to set up
stdin/stdout for these processes.

For example, when spawning 'cat' above the shell does:

        o fork(2) to create new process image
        < in the child (newly created) process image >
        o pipe(2) to create a pipe -- this gives us two file descriptors,
          one for writing and one for reading
        o dup(2) to make stdout (file descriptor # 1) the writing end
          of the pipe
        o exec(2) to run 'cat' in the current process image

When starting 'uudecode' the shell does:

        o fork(2) to create new process image
        < in the child (newly created) process image >
        o dup(2) to make stdin (file descriptor # 0) the reading end of
          the pipe created when we spawning 'cat'
        o open a file called 'blah'
        o dup(2) to make stdout (file descriptor # 1) point to 'blah'
        o exec(2) to run 'uudecode' in the current process image

That's over-simplifying things a bit, but you get the idea.

        -- Adam

On Thu, 29 Jul 1999, ROLF LEMKE wrote:

> I guess this is a sorta linux/unix question so here goes:
> I have a uuencoded (7bit ascii) file that I want to extract but the
> problem is that it is in 8 parts. How do i go about sticking all the
> pieces together? Is there a utility for doing this in RedHat?
>
> cheers
>
> *****************************************************
> I am Homer of Borg, Resistance is .... hmmm Donuts. *
> *****************************************************
>
> -
> Saskatoon Linux Group Mailing List.
> -
> To unsubscribe, send mail to
> 'linux-request@slg.org' with
> 'unsubscribe' in the body.
>

-
Saskatoon Linux Group Mailing List.
-
To unsubscribe, send mail to
'linux-request@slg.org' with
'unsubscribe' in the body.
Received on Tue Jul 27 12:46:54 1999

This archive was generated by hypermail 2.1.8 : Sun Jan 09 2005 - 13:53:59 CST