Uudecode linux что это

Обновлено: 30.06.2024

UUE (англ. Uuencode ) — метод представления двоичных данных в текстовой форме, пригодной для передачи через средства, предназначенные только для передачи текстов (например, через e-mail, FTN, транспортное кодирование).

Название происходит от расшифровки названия программ uuencode/uudecode: Unix-To-Unix encoding (decoding). В дальнейшем UUE в интернет-среде (почта, ньюсгруппы) был заменён на Фидонет.

Юю́ки — жаргонное наименование UUE-кодов в Фидонете.

Содержание

Описание формата

UUE данные начинаются со строки begin mode file , где mode — Unix-права доступа к файлу в восьмиричной системе счисления (для DOS/Windows приложений это число всегда 644), а file — имя исходного файла.

При кодировании из файла берутся данные по три байта (в случае, если осталось меньше 3 байт, недостающие заменяются нулями). 24 бита, образующие эти три байта, делятся на четыре группы по 6 бит. Каждая шестибитная группа интерпретируется как число (от 0 до 2 6 − 1 = 63 ), к которому добавляется 32. Получившееся число в диапазоне от 32 до 95 трактуется как код символа в

Каждая группа из 60 символов (соответствует 45 байтам исходного файла) используется для создания отдельной строки. В начале строки указывается количество закодированных символов в строке (во всех строках, кроме последней это число 45, то есть символ 'M'). Каждая строка завершается символом перевода строки (\n или \n\r в зависимости от платформы).

После окончания данных кодируемого файла помещается строка, содержащая единственный пробел (и перевод строки), и строка с текстом «end».

Иногда в конце строки данных добавляют «пустые символы», обычно символ ` (младшие 6 битов которого равны нулю) для предотвращения повреждения строк некоторыми почтовыми программами.

Пример кодирования

Пример кодирования английского слова Cat.

Исходные символы C a t
ASCII коды (десятич.) 67 97 116
ASCII (двоичн.) 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 0 0
Новые десятичные значения 16 54 5 52
+32 48 86 37 84
Символы UUE 0 V % T

Итоговый результат (закодировано слово Cat):

Таблица используемых символов UUE

Недостатки

  • За счёт использования только 6 битов из 8, потери при кодировании в UUE составляют 33 % (файл размером 1000 Кб займёт 1333 Кб в UUE).
  • Несмотря на узкий диапазон используемых символов, возникают проблемы при передаче UUE через старые компьютеры, использующие не ASCII кодировку (например,

Особенности использования UUE в Фидонете

Для обеспечения совместимости со старым программным обеспечением [2] размер письма во многих эхоконференциях до 2004‑2005 года ограничивался величиною, например, 32 кБ. С учётом служебной информации, добавляемой при распространении почты по Фидонету, письму не рекомендовалось превосходить размер 500 строк (

22 кБ оригинального файла). Файлы большего размера передаются в нескольких письмах, каждое такое письмо содержит одну секцию UUE. При этом в заголовке письма обычно указывается порядковый номер секции, а также общее число секций (в виде [6/55] , где 6 — номер текущей секции, а 55 — общее число секций). Начальный номер секции различается в зависимости от используемого программного обеспечения (0 или 1).

В эхоконференциях возможность использовать UUE регулируется правилами конференции; согласно требованию эхополиси R50, для принятия конференции на региональный бон в её правилах должно быть прописано ограничение на помещение UUE. [3] Существует множество небонных (не находящихся на региональном эхобоне) конференций, специализирующихся на передаче UUE-кодов.

These commands encode and decode files as follows:

uuencode

The uuencode utility converts a binary file into an encoded representation that can be sent using mail (1). It encodes the contents of source-file , or the standard input if no source-file argument is given. The decode_pathname argument is required. The decode_pathname is included in the encoded file's header as the name of the file into which uudecode is to place the binary (decoded) data. uuencode also includes the permission modes of source-file (except setuid , setgid , and sticky-bits), so that decode_pathname is recreated with those same permission modes.

uudecode

The uudecode utility reads an encoded-file , strips off any leading and trailing lines added by mailer programs, and recreates the original binary data with the filename and the mode specified in the header.

The encoded file is an ordinary portable character set text file; it can be edited by any text editor. It is best only to change the mode or decode_pathname in the header to avoid corrupting the decoded binary.

OPTIONS

The following options are supported:

uuencode

-m Encodes source-file using Base64 encoding and sends it to standard output.

uudecode

-o outfile Specifies a file pathname that should be used instead of any pathname contained in the input data. Specifying an outfile option-argument of /dev/stdout indicates standard output.This allows uudecode to be used in a pipeline.

-p Decodes encoded-file and sends it to standard output. This allows uudecode to be used in a pipeline.

OPERANDS

The following operands are supported by uuencode and uudecode :

uuencode

decode_pathname The pathname of the file into which the uudecode utility will place the decoded file. If there are characters in decode_pathname that are not in the portable filename character set, the results are unspecified.

source-file A pathname of the file to be encoded.

uudecode

encoded-file The pathname of a file containing the output of uuencode .

USAGE

See largefile (5) for the description of the behavior of uuencode and uudecode when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).

ENVIRONMENT VARIABLES

See environ (5) for descriptions of the following environment variables that affect the execution of uuencode and uudecode : LANG , LC_ALL , LC_CTYPE , LC_MESSAGES , and NLSPATH .

OUTPUT

uuencode Base64 Algorithm

The standard output is a text file, encoded in the character set of the current locale, that begins with the line:

and ends with the line:

In both cases, the lines have no preceding or trailing blank characters.

The character referenced by the index is placed in the output string.

The output stream (encoded bytes) is represented in lines of no more than 76 characters each. All line breaks or other characters not found in the table are ignored by decoding software (see uudecode ).

Special processing is performed if fewer than 24 bits are available at the end of a message or encapsulated part of a message. A full encoding quantum is always completed at the end of a message. When fewer than 24 input bits are available in an input group, zero bits are added on the right to form an integral number of 6-bit groups. Output character positions that are not required to represent actual input data are set to the equals ( = ) character. Since all Base64 input is an integral number of octets, only the following cases can arise: 1. The final quantum of encoding input is an integral multiple of 24 bits. Here, the final unit of encoded output is an integral multiple of four characters with no ' = ' padding. 2. The final quantum of encoding input is exactly 16 bits. Here, the final unit of encoded output is three characters followed by one ' = ' padding character. 3. The final quantum of encoding input is exactly 8 bits. Here, the final unit of encoded output is two characters followed by two ' = ' padding characters.

A terminating " ==== " evaluates to nothing and denotes the end of the encoded data.

uuencode Historical Algorithm

The standard output is a text file (encoded in the character set of the current locale) that begins with the line:

and ends with the line:

In both cases, the lines have no preceding or trailing blank characters.

The algorithm that is used for lines between begin and end takes three octets as input and writes four characters of output by splitting the input at six-bit intervals into four octets, containing data in the lower six bits only. These octets are converted to characters by adding a value of 0x20 to each octet, so that each octet is in the range 0x20-0x5f , and each octet is assumed to represent a printable character. Each octect is then translated into the corresponding character codes for the codeset in use in the current locale. For example, the octet 0x41 , representing ' A ', would be translated to ' A ' in the current codeset, such as 0xc1 if the codeset were EBCDIC .

Where the bits of two octets are combined, the least significant bits of the first octet are shifted left and combined with the most significant bits of the second octet shifted right. Thus, the three octets A , B , C are converted into the four octets:

These octets are then translated into the local character set.

Each encoded line contains a length character, equal to the number of characters to be decoded plus 0x20 translated to the local character set as described above, followed by the encoded characters. The maximum number of octets to be encoded on each line is 45.

EXIT STATUS

The following exit values are returned:

0 Successful completion.

>0 An error occurred.

ATTRIBUTES

See attributes (5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
AvailabilitySUNWesu
Interface Stability

SEE ALSO

NOTES

The size of the encoded file is expanded by 35% (3 bytes become 4, plus control information), causing it to take longer to transmit than the equivalent binary.

The user on the remote system who is invoking uudecode (typically uucp ) must have write permission on the file specified in the decode_pathname .

If you invoke uuencode and then execute uudecode on a file in the same directory, you will overwrite the original file.

The utility reads file (or by default the standard input) and writes an encoded version to the standard output, or output_file if one has been specified. The encoding uses only printing ASCII characters and includes the mode of the file and the operand name for use by uudecode

The uudecode utility transforms uuencoded files (or by default, the standard input) into the original form. The resulting file is named either name or (depending on options passed to uudecode output_file and will have the mode of the original file except that setuid and execute bits are not retained. The uudecode utility ignores any leading and trailing lines.

The following options are available for :

-m Use the Base64 method of encoding, rather than the traditional algorithm. -o output_file Output to output_file instead of standard output.

The following options are available for uudecode

-c Decode more than one uuencoded file from file if possible. -i Do not overwrite files. -m When used with the - r flag, decode Base64 input instead of traditional input. Without - r it has no effect. -o output_file Output to output_file instead of any pathname contained in the input data. -p Decode file and write output to standard output. -r Decode raw (or broken) input, which is missing the initial and possibly the final framing lines. The input is assumed to be in the traditional encoding, but if the - m flag is used, or if the utility is invoked as b64decode then the input is assumed to be in Base64 format. -s Do not strip output pathname to base filename. By default uudecode deletes any prefix ending with the last slash '/' for security reasons.

EXAMPLES

The following example packages up a source tree, compresses it, uuencodes it and mails it to a user on another system. When uudecode is run on the target system, the file ``src_tree.tar.Z'' will be created which may then be uncompressed and extracted into the original tree.

The following example unpacks all uuencoded files from your mailbox into your current working directory.

The following example extracts a compressed tar archive from your mailbox

Uuencode and uudecode are used to transmit binary files over transmission mediums that do not support other than simple ASCII data.

Uuencode reads file (or by default the standard input) and writes an encoded version to the standard output. The encoding uses only printing ASCII characters and includes the mode of the file and the operand name for use by uudecode. If name is /dev/stdout the result will be written to standard output. By default the standard UU encoding format will be used. If the option -m is given on the command line base64 encoding is used instead.

Note: uuencode uses buffered input and assumes that it is not hand typed from a tty. The consequence is that at a tty, you may need to hit Ctl-D several times to terminate input.

Uudecode transforms uuencoded files (or by default, the standard input) into the original form. The resulting file is named name (or outfile if the -o option is given) and will have the mode of the original file except that setuid and execute bits are not retained. If outfile or name is /dev/stdout the result will be written to standard output. Uudecode ignores any leading and trailing lines. The program can automatically decide which of the two supported encoding schemes are used.

Examples

The following example packages up a source tree, compresses it, uuencodes it and mails it to a user on another system. When uudecode is run on the target system, the file ''src_tree.tar.Z'' will be created which may then be uncompressed and extracted into the original tree. tar cf - src_tree | compress | uuencode src_tree.tar.Z | mail sys1!sys2!user

See Also

Standards

This implementation is compliant with P1003.2b/D11.

If more than one file is given to uudecode and the -o option is given or more than one name in the encoded files are the same the result is probably not what is expected.

The encoded form of the file is expanded by 37% for UU encoding and by 35% for base64 encoding (3 bytes become 4 plus control information).

Uuencode and uudecode are used to transmit binary files over transmission mediums that do not support other than simple ASCII data.

Uuencode reads file (or by default the standard input) and writes an encoded version to the standard output. The encoding uses only printing ASCII characters and includes the mode of the file and the operand name for use by uudecode. If name is /dev/stdout the result will be written to standard output. By default the standard UU encoding format will be used. If the option -m is given on the command line base64 encoding is used instead.

Note: uuencode uses buffered input and assumes that it is not hand typed from a tty. The consequence is that at a tty, you may need to hit Ctl-D several times to terminate input.

Uudecode transforms uuencoded files (or by default, the standard input) into the original form. The resulting file is named name (or outfile if the -o option is given) and will have the mode of the original file except that setuid and execute bits are not retained. If outfile or name is /dev/stdout the result will be written to standard output. Uudecode ignores any leading and trailing lines. The program can automatically decide which of the two supported encoding schemes are used.

Examples

The following example packages up a source tree, compresses it, uuencodes it and mails it to a user on another system. When uudecode is run on the target system, the file ''src_tree.tar.Z'' will be created which may then be uncompressed and extracted into the original tree. tar cf - src_tree | compress | uuencode src_tree.tar.Z | mail sys1!sys2!user

See Also

Standards

This implementation is compliant with P1003.2b/D11.

If more than one file is given to uudecode and the -o option is given or more than one name in the encoded files are the same the result is probably not what is expected.

The encoded form of the file is expanded by 37% for UU encoding and by 35% for base64 encoding (3 bytes become 4 plus control information).

Читайте также: