Various nuggets of useful technical information.

Thursday, June 19, 2008

Attaching files from command line in Linux

One needs to have the linux utilities uuencode and uudecode installed.

uuencode/uudecode are in the sharutils package, which may not be installed by default.

[root@gghbkup source_disks]# find ./* -name "sharutil*"
./disk5/Fedora/RPMS/sharutils-4.6.1-2.i386.rpm
[root@gghbkup source_disks]# cd disk5/Fedora/RPMS/
[root@gghbkup RPMS]# rpm -Uvh sharutils-4.6.1-2.i386.rpm
Preparing... ########################################### [100%]
1:sharutils ########################################### [100%]
[root@gghbkup RPMS]# which uuencode
/usr/bin/uuencode
[root@gghbkup RPMS]# which uudecode
/usr/bin/uudecode

Say you want to attach test.iso to an email to yourself:

uuencode test_attachment test.iso > testattach.uu
echo "This is the email body" > mail.body
cat mail.body testattach.uu | mail -s "test email" temp@tempemailaccount.com

And it comes through an email with test.iso attached. Works with Tbird and Outlook.


No comments: