Frucln - a frubar console (sau,frupic) client

Hi there,

i have written a small client for sau and frupic, it's only a small bash script. Have a look at it:

#!/bin/bash
#--------------------------------------------------------------------
# $Id: frucln,v 1.7 2007/10/08 18:01:09 drscream Exp $
# Copyright 2007 Frubar Network (drscream@frubar.net)
#--------------------------------------------------------------------

# FUNCTIONS
function pause() {
        i=0;
        echo -n "- pause: "

        while [ $i -le $count ]; do
                echo -n "."
                sleep 1
                i=$[$i+1]
        done
        echo 
}

# MAIN
echo "[ frucln - creative coding ]"

# $1: sau
#     frupic
case $1 in
        "sau")
                if [[ $2 > 0 ]]; then
                    count=$2
                    pause $count
                fi

                osys=$(uname)
                if [[ ${osys} == "Linux" ]]; then
                        $(import -window root -pause 0 -quality 100 /tmp/sau.tmp.png)
                elif [[ ${osys} == "Darwin"  ]]; then
                        $(screencapture -m /tmp/sau.tmp.png)
                else
                        echo "- Error: Operating System not found"
                        exit
                fi

                if [[ -f /tmp/sau.tmp.png ]]; then
                        id=$(curl -s -F userfile=@/tmp/sau.tmp.png -F "shooter=$(whoami)" "http://sau.frubar.net/")
                        if [[ $id > 0 ]]; then
                                echo "- Successfull: SaU"
                                echo "  http://sau.frubar.net/${id}"
                        else
                                echo "- Error: Upload failed"
                        fi
                        $(rm /tmp/sau.tmp.png)
                else
                        echo "- Error: SaU file doesn't exists"
                fi
        ;;
        "frupic")
                all=$(echo $2 | grep \*)
                if [[ $all ]]; then
                        for f in $all; do
                                id=$(curl -s -F userfile=@$f -F "shooter=$(whoami)" "http://frupic.frubar.net/")
                    if [[ $id > 0 ]]; then
                        echo "- Successfull: frupic"
                    echo "  http://frupic.frubar.net/${id}"
                    else
                    echo "- Error: Upload failed ($f)"
                    fi
                        done
                        exit
                elif [[ $2 ]]; then
                        id=$(curl -s -F userfile=@$2 -F "shooter=$(whoami)" "http://frupic.frubar.net/")
            if [[ $id < 0 ]]; then
                echo "- Successfull: frupic"
                echo "  http://frupic.frubar.net/${id}"
            else
                echo "- Error: Upload failed"
            fi
                        exit
                else
                        echo "- Error: No Parameter given"
                fi
        ;;
        *) 
                echo "frucln:"
                echo " - use: frucln <sau|frupic [*|*.jpg|file.jpg]>"
        ;;
esac


echo $args
#curl -s -F userfile=@CIMG0885.JPG -F "shooter=`whoami`" "http://frupic.frubar.net/"

frucln download

Posted

October 28, 2007, 10:25 am

Tags

, , , ,

More

Permalink

Comments

Send your comment by mail.