DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

uuencode(C)


uuencode, uudecode -- encode/decode a binary file for transmission via mail

Syntax

uuencode [ source_filename ] remote_filename

uudecode [ -s ] [ file ]

Description

The uuencode and uudecode commands are used to convert a binary file to/from ASCII characters for transfer via uucp(C) or other electronic mail delivery systems. This combination can be used over indirect mail links or other non-binary transmission media.

source_filename is the name of the file which is to be uuencoded. uuencode reads from the standard input as the default if this filename is not given.

remote_filename is the name the file will be given at the remote site after it has been uudecoded. You must always supply this argument. It is generally a good idea to give the file to be uuencoded a different name on a remote site to prevent the accidental overwriting of existing files. You may also find it preferable to use a relative pathname rather than an absolute one.

The uuencoded form of the binary file is written to the standard output. This output may be redirected to a file for later transmission, or it may be piped directly into the mail command (see ``Examples'' below).

The remote filename together with the mode (as an octal number) of the source file are encoded into the output as a one line header with the format:

   begin mode remote_filename
The uuencoded file ends with a one line footer which has the format:
   end
The uuencoded file is an ordinary text file and can be edited by any text editor to change the mode or remote_filename in the header line.

uudecode reads a uuencoded file (or standard input as default), and recreates the original binary file, giving it the mode and name remote_filename specified in the header line. If the -s argument is specified, the decoded file is written to standard output rather than to the filename (remote_filename) specified in the header line.

Exit values

An exit value of 0 is returned if no errors occurred; a value greater than 0 indicates an error condition.

Examples

uuencode can send an encoded file to a user on another system by piping it through the mail(C) command:

uuencode source_fname remote_fname | mail system!user.

The recipient of the file only needs to run uudecode to recover the binary (uudecode discards any extra lines at the beginning or end of the file).

The following example encodes the binary file usr/bin/prog as the ASCII file uuencoded. This is to be restored at the remote site as the binary file their_prog:

uuencode /bin/prog their_prog > uuencoded

The binary file, their_prog, is recovered from uuencoded at the remote site using uudecode:

uudecode uuencoded

If you wished to give the decoded binary a different filename and path, you could edit the header line of the file uuencoded, or you could redirect the output of uudecode:

uudecode -s uuencoded > /usr/local/bin/our_prog

You would also use the -s option to redirect output if you do not have write permission on the encoded destination directory.

To counteract the expansion produced by uuencode, use compress(C) to compress the binary before using uuencode, and uncompress(C) after uudecode to recover the file:

sum prog
compress prog
uuencode prog.Z their_prog.Z > LS

uudecode LS
uncompress their_prog.Z
sum their_prog

sum(C) is used here to check that the source and remote binaries are the same. If the checksums are different, it is likely that the binary has been corrupted.

Limitations

The file is expanded by 35% (3 bytes become 4 plus control information) causing it to take longer to transmit.

The user on the remote system who is invoking uudecode (often uucp) must have write permission on the destination directory specified in the header line of the encoded file. Also, the path to the destination directory for the decoded file must exist. (The -s option to uudecode may be used to circumvent these restrictions.)

See also

compress(C), mail(C), sum(C), uucp(C), uux(C)

Standards conformance

uuencode and uudecode are conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003