Uuencode

From Bashlinux
Revision as of 07:33, 9 November 2012 by Manpaz (talk)
Jump to: navigation, search

uuencode

This is technique is useful to embed a binary file on a script. First ensure to have the proper package installed

 yum -y install sharutils
 


How to encode binary files to text

Execute the following command

 /usr/bin/uuencode /path/to/binary/file -
 

Note the hyphen at the end of the command

How to decode text files to binary

To restore a binary file from text copy the result string from stdin to your script as follows

 /usr/bin/uudecode > /path/to/binary/file << 'EOF'
 begin 644 -
 M````!'\```$``3``$DU)5"U-04=)0RU#3T]+244M,0`0(581,6(<1J&_0`OE
 M_:%-L@$``!5L;V-A;&AO<W0N;&]C86QD;VUA:6X``3``$DU)5"U-04=)0RU#
 93T]+244M,0`0(581,6(<1J&_0`OE_:%-L@``
 `
 end
 EOF
 

The output of the above command always must be redirected to a file.