Thursday, September 29, 2011

(off-topic) Quick method of sending files from ssh to clients

Hey,

Little bit off topic, but quite relevant for the busy coder. 

Often I needed to quickly grab a file off a server, or send to a client, but it took me 2-3 minutes to fire up an SCP client, find the file, send it etc etc.

So I created a small script (depends on sendmail and uuencode/sharutils) to send files via email:

 foxx@sws01.internal [~] > cat /usr/sbin/sendfile
#!/bin/sh
if [ -z "$1" ] || [ -z "$2" ] || [ ! -f $1 ] ; then
    echo "syntax: [filename] [email address]"
else
    (echo "file attached."; uuencode $1 $1) | mail -s "file attach: $1" $2
    echo "File sent to $2"
fi

Usage:

 foxx@sws01.internal [~] > /usr/sbin/sendfile ~/lol cal.leeming@simplicitymedialtd.co.uk

Hopefully someone else will benefit from these 6 lines of code which saved me so much time :)

Cal

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment