xref: /freebsd/usr.bin/bintrans/bintrans.1 (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd January 23, 2024
29.Dt BINTRANS 1
30.Os
31.Sh NAME
32.Nm bintrans ,
33.Nm uuencode ,
34.Nm uudecode ,
35.Nm b64encode ,
36.Nm b64decode ,
37.Nm base64
38.Nd encode / decode a binary file
39.Sh SYNOPSIS
40.Nm
41.Op algorithm
42.Op ...
43.Nm uuencode
44.Op Fl m
45.Op Fl r
46.Op Fl o Ar output_file
47.Op Ar file
48.Ar name
49.Nm uudecode
50.Op Fl cimprs
51.Op Ar
52.Nm uudecode
53.Op Fl i
54.Fl o Ar output_file
55.Nm b64encode
56.Op Fl r
57.Op Fl w Ar column
58.Op Fl o Ar output_file
59.Op Ar file
60.Ar name
61.Nm b64decode
62.Op Fl cimprs
63.Op Ar
64.Nm b64decode
65.Op Fl i
66.Fl o Ar output_file
67.Op Ar file
68.Nm base64
69.Op Fl d
70.Op Fl w Ar column
71.Op Ar file
72.Sh DESCRIPTION
73The
74.Nm uuencode
75and
76.Nm uudecode
77utilities are used to transmit binary files over transmission mediums
78that do not support other than simple
79.Tn ASCII
80data.
81The
82.Nm b64encode
83utility is synonymous with
84.Nm uuencode
85with the
86.Fl m
87flag specified.
88The
89.Nm b64decode
90utility is synonymous with
91.Nm uudecode
92with the
93.Fl m
94flag specified.
95.Pp
96The
97.Nm base64
98utility acts as a base64 decoder when passed the
99.Fl -decode
100.Po or
101.Fl d
102.Pc
103flag and as a base64 encoder otherwise.
104As a decoder it only accepts raw base64 input
105and as an encoder it does not produce the framing lines.
106.Nm base64
107reads standard input or
108.Ar file
109if it is provided and writes to standard output.
110Options
111.Fl -wrap
112.Po or
113.Fl w
114.Pc
115and
116.Fl -ignore-garbage
117.Po or
118.Fl i
119.Pc
120are accepted for compatibility with GNU base64,
121but the latter is unimplemented and silently ignored.
122.Pp
123The
124.Nm uuencode
125utility reads
126.Ar file
127(or by default the standard input) and writes an encoded version
128to the standard output, or
129.Ar output_file
130if one has been specified.
131The encoding uses only printing
132.Tn ASCII
133characters and includes the
134mode of the file and the operand
135.Ar name
136for use by
137.Nm uudecode .
138.Pp
139The
140.Nm uudecode
141utility transforms
142.Em uuencoded
143files (or by default, the standard input) into the original form.
144The resulting file is named either
145.Ar name
146or (depending on options passed to
147.Nm uudecode )
148.Ar output_file
149and will have the mode of the original file except that setuid
150and execute bits are not retained.
151The
152.Nm uudecode
153utility ignores any leading and trailing lines.
154.Pp
155The following options are available for
156.Nm uuencode :
157.Bl -tag -width indent
158.It Fl m
159Use the Base64 method of encoding, rather than the traditional
160.Nm uuencode
161algorithm.
162.It Fl r
163Produce raw output by excluding the initial and final framing lines.
164.It Fl o Ar output_file
165Output to
166.Ar output_file
167instead of standard output.
168.El
169.Pp
170The following options are available for
171.Nm uudecode :
172.Bl -tag -width indent
173.It Fl c
174Decode more than one uuencoded file from
175.Ar file
176if possible.
177.It Fl i
178Do not overwrite files.
179.It Fl m
180When used with the
181.Fl r
182flag, decode Base64 input instead of traditional
183.Nm uuencode
184input.
185Without
186.Fl r
187it has no effect.
188.It Fl o Ar output_file
189Output to
190.Ar output_file
191instead of any pathname contained in the input data.
192.It Fl p
193Decode
194.Ar file
195and write output to standard output.
196.It Fl r
197Decode raw (or broken) input, which is missing the initial and
198possibly the final framing lines.
199The input is assumed to be in the traditional
200.Nm uuencode
201encoding, but if the
202.Fl m
203flag is used, or if the utility is invoked as
204.Nm b64decode ,
205then the input is assumed to be in Base64 format.
206.It Fl s
207Do not strip output pathname to base filename.
208By default
209.Nm uudecode
210deletes any prefix ending with the last slash '/' for security
211reasons.
212.El
213.Pp
214Additionally,
215.Nm b64encode
216accepts the following option:
217.Bl -tag -width indent
218.It Fl w Ar column
219Wrap encoded output after
220.Ar column .
221.El
222.Pp
223.Nm
224is a generic utility that can run
225any of the aforementioned encoders and decoders.
226It can also run algorithms that are not available
227through a dedicated program:
228.Pp
229.Nm qp
230is a quoted-printable converter
231and accepts the following options:
232.Bl -tag -width indent
233.It Fl u
234Decode.
235.It Fl o Ar output_file
236Output to
237.Ar output_file
238instead of standard output.
239.El
240.Sh EXAMPLES
241The following example packages up a source tree, compresses it,
242uuencodes it and mails it to a user on another system.
243When
244.Nm uudecode
245is run on the target system, the file ``src_tree.tar.Z'' will be
246created which may then be uncompressed and extracted into the original
247tree.
248.Pp
249.Bd -literal -offset indent -compact
250tar cf \- src_tree \&| compress \&|
251uuencode src_tree.tar.Z \&| mail user@example.com
252.Ed
253.Pp
254The following example unpacks all uuencoded
255files from your mailbox into your current working directory.
256.Pp
257.Bd -literal -offset indent -compact
258uudecode -c < $MAIL
259.Ed
260.Pp
261The following example extracts a compressed tar
262archive from your mailbox
263.Pp
264.Bd -literal -offset indent -compact
265uudecode -o /dev/stdout < $MAIL | zcat | tar xfv -
266.Ed
267.Sh SEE ALSO
268.Xr basename 1 ,
269.Xr compress 1 ,
270.Xr mail 1 ,
271.Xr uucp 1 Pq Pa ports/net/freebsd-uucp ,
272.Xr uuencode 5
273.Sh HISTORY
274The
275.Nm uudecode
276and
277.Nm uuencode
278utilities appeared in
279.Bx 4.0 .
280.Sh BUGS
281Files encoded using the traditional algorithm are expanded by 35% (3
282bytes become 4 plus control information).
283