Image Up

index | bash

a quick-n-dirty script to copy an image (or other file) to your server.

I basically use this to upload screenshots for display here on this wiki and my blog, etc., so have the images directory “hardwired” in the script, but this could easily be customized to choose a different directory and use with any manner of files.

# script to upload images to my server
# by tony baldwin
if [ ! $1 ]; then
        # If you didn't tell it which file, it asks here
	read -p "Which image, pal? " img
        img = $1
# using scp to copy the file to the server
scp $img username@server_url_or_IP_address:/path/to/directory/html/images/
# you will be asked for your password, of course.  This is a function of scp, so not written into the script.
echo "Your image is now at$img."
read -p "Would you like to open it in your a browser now? (y/n): " op
if [ $op = "y" ]; then
	# you can replace xdg-open with with your favorite browser, but this should choose your default browser, anyway.
        # if you chose yes, the browser will open the image. 
        # Otherwise, it won't, but you have the url, so you can copy/paste to a browser or html document, blog entry, tweet, etc., at will.

This image was uploaded with the above script:

editing website with tcltext

(editing website with tcltext)


tonybaldwin September 04, 2011, at 12:36 PM