ZmllZCB3aXRoIGFueSBidXQgdGhlIHNtYWxsZXN0IGlucHV0IHRleHRzLgo= IDx+ICkgYW5kIDIgYXQgdGhlIGVuZCAoIH4+ICkgc28gaXQgaGFzIGEgbGl0dGxlIGRpc2FkdmFuĭGFnZSBvdmVyIGJhc2U2NCBtaW1lIGVuY29kaW5nLCBidXQgdGhhdCBpcyBxdWlja2x5IG51bGxp Q0lJODUgZW5jb2RpbmcgYWRkcyBhbiBleHRyYSB0d28gYnl0ZXMgYXQgdGhlIGJlZ2lubmluZyAo VGhpcyBpcyB0aGUgaW5wdXQgdGV4dCB1c2VkIGluIHRoZSBlbmNvZGluZyBjb21wYXJpc29ucyB0ĪGF0IGFyZSB0byBmb2xsb3cuICBJJ20gbWFraW5nIHRoaXMgbG9uZyBlbm91Z2ggc28gdGhhdCBvĭmVyaGVhZCB3aWxsIG5vdCBiZSB0b28gc2lnbmlmaWNhbnQgaW4gICB0aGUgcmVzdWx0cy4gIEFT P=0 if(!getline ) so it has a little disadvantage over base64 mime encoding, but that is quickly nullified with any but the smallest input texts." Note that if you plan on running these on Solaris, use the /usr/xpg4/bin versions of awk and od as the other ones are quite brain-dead. You can find the scripts in the attachments, but they're pasted here for your perusal pleasure, or masochism.īoth of these scripts are less than one kilo-byte each. I then shortened the script as much as possible to reduce size, so it's almost unreadable I'm afraid.Īfter a while, I discovered an article about ASCII85 on wikipedia and wrote an awk implementation of it using the same tricks I had used for base64. This worked great, I could then include a shell function that calls awk right and then pipe "here-document" data through the function and then pipe the output into tar. Solution: have awk use od (octal dump) convert the input from binary to decimal values. The problem with awk is that it lacks the ability to read pure binary data to do encoding. Doing it in pure bourne shell was possible but very very slow, so I looked at awk. I didn't want my shell script to try to compile my own because there was no guarantee that all targets had a C compiler. I looked at base 64 mime encoding but that required utilities that may or may not exist on all target systems. Hex, however is wasteful it's a 2:1 ratio. In another project I needed a self-contained shell script to extract a bunch of images from a tar archive but I didn't want the extra file so I included a hex dump of the tar file in the script and decoded it at run time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |