#!/bin/bash read -e -p "Enter your status: " status test -z "$status" && exit 1 test -z "$TWITTER_USER" && read -e -p "Enter your Twitter username: " TWITTER_USER test -z "$TWITTER_PASS" && read -s -p "Enter your Twitter password: " TWITTER_PASS echo while true; do read -e -p "Choose an image to upload to TwitPic (optional): " image test -z "$image" && break ext=$(echo ${image##*.} | tr "[:upper:]" "[:lower:]") if [ -f $image -a \( $ext = gif -o $ext = jpg -o $ext = jpeg -o $ext = png \) ]; then break fi echo "Please choose a valid image file (GIF, JPG, or PNG)" done if [ -n "$image" ]; then echo "Posting to TwitPic..." curl -k -F "media=@$image" -F "username=$TWITTER_USER" -F "password=$TWITTER_PASS" -F "message=$status" https://twitpic.com/api/uploadAndPost echo else echo "Posting to Twitter..." curl -k -u $TWITTER_USER:$TWITTER_PASS -d status="$status" https://twitter.com/statuses/update.xml fi