rearsync.com Sync’n since 2008…
Categories: Computers, Networking, Security, linux, unix

Sometimes I find myself needing to get a file off of a box in a timely manner, but I dont really feel like playing with SCP or FTP.  I know, I know, I just wrote a post about how awesome SCP is, but sometimes I just need the file right NOW :)

We could use ‘nail’ very easily for this, but of most of the boxes I have to use lately only have sendmail available.  Since sendmail doesn’t have an explicit ‘attachment’ option like nail does, it can still be done, and heres how. You ‘cat’ out a file and pipe it through uuencode (you remember that right? :) )  and then out through sendmail.  This also works great in a shellscript.

Example:

File I want is -

filename.pgp

Run the command like this.

cat filename.pgp | uuencode filename.pgp | sendmail mcnooby@n00b.com

Shortly you should have an email in your email box (assuming the spam filter doesn’t get it first) with your filename as an attachment.  By default the email will be from your_username@hostname, if you want to change this you can use the ‘-f’ flag with sendmail.  You can even set your sendmail up to relay if you really want to get fancy.  I’m still trying to figure out how to get a message body, since this method will only allow me just to attach a file.  As always check out ~# man sendmail for all the other fun stuff.

Have fun, remember this is a very simple way to use it, so play around and do fun stuff.  And respect & <3 the |  .

Nick