Using uuencode to embed binaries in scripts and copy/paste transfer files between servers
brian_s 270002K5X3 Visits (6941)
The uuencode utility converts binary to text, and uudecode converts the text back to binary. Wikipedia has a great article on the details of how this proces works (htt
Embeding binary files in a script
If you have a script that also needs to include a binary file, you can uuencode it and include it within the script itself. So if you are writing a script to install/setup a binary you could actually also embed the binary within the script itself.
Here is an example of what this would look like:
To get the uuencode output of the binary run a command like this: uuencode /usr/bin/ls /dev/stdout . Take the output and replace the "<insert uuencode output of the binary here>" text in the example with the uuencode output.
When the script runs, the file will be extracted.
Copy/Paste transfer files across servers
If you have a relatively small binary file that you need to transfer between servers, you can easily transfer it by copying and pasting it using uuencode/uudecode. This can be a time saver in some circumstances. It also might be helpful if you have a server that isn't connected to the network but for which you can get a console on through something like the HMC.
In this example, we will copy and paste the /usr/bin/ls binary between servers.
On the source server, type:
uuencode /usr/bin/ls /dev/stdoutThen copy all of the output in to the clipboard.
On the destination server, type:
uudecode -o /tmp/lsThen press enter, and then paste in the uuencode output from the source server. The copy/pasted "ls" binary will be saved to /tmp/ls. You can verify the source and destination "ls" files are identical by comparing the checksum of the files with the "csum" command.