Linux Blog

Halloween Pumpkin

Filed under: General Linux — TheLinuxBlog.com at 12:15 am on Friday, October 30, 2009

For Halloween this year every department at work was asked to carve or decorate a pumpkin. Since I’m in IT I thought I’d take the task of decorating our pumpkin with something IT related that would scare the crap out of everyone. Most of our end users are actually Windows users, so this pumpkin should be especially scary to them.

I introduce the B.S.O.Dkin, yes it’s a B.S.O.D pumpkin

B.S.O.D Pumpkin.

B.S.O.D Pumpkin.

I’d like to say it looks better in person, but it really doesn’t. I don’t really have an artsy knack for carving or painting pumpkins or I could have done something a lot better.

I guess my “Halloween Costume” is a blue Mexican wrestlers mask, blue t-shirt, and jeans to complete the B.S.O.D theme. With as much hate as I’ve been giving Microsoft recently I’m going to have to keep my fingers crossed for no kernel panics. Karma might bite me.

Coppermine Photo gallery Upload Script

Filed under: Shell Script Sundays — TheLinuxBlog.com at 9:15 pm on Sunday, May 31, 2009

This week I bring you a script that I helped Kaleb (who has written posts here before) write. Well, I got him started with it, using curl and he rolled with it and finished it up. Here is the script:

#!/bin/bash
# Script to Upload to http://kporter.homelinux.com/~kaleb/cpg14x
# Written by Kaleb Porter May 23 2009
# with help of www.thelinuxblog.com
# email: porterboy55@gmail.com
# if you wish to use this code for something else please give me credit

IMAGE=”$1″
URL=”http://kporter.homelinux.com/~kaleb/cpg14x/upload.php”
DA=`date ‘+%d%b%y-%N’`
# If the user does not specify a file or url
if [ -z "$1" ]; then
echo “You did not give a file to upload”
echo “Takeing a screenshot in 3 Seconds…”
sleep 3
scrot $DA.png
IMAGE=$DA.png
fi
FI=`echo “$IMAGE” | grep ‘^[a-z]*://’`
AL=2
FIUP=`curl -s -F control=phase_1 -F blaa=continue -F file_upload_array[]=@$IMAGE $URL | grep unique_ID | awk -F\” ‘{print $6}’`
URLUP=`curl -s -F control=phase_1 -F blaa=continue -F URI_array[]=$IMAGE $URL | grep unique_ID | awk -F\” ‘{print $6}’`

#Get the title for the image from the user and change all the spaces to “%20″
echo “Enter a title for the image”
read TITLE1
TITLE=`echo $TITLE1 | sed ‘s/ /\%20/g’`

#Get the Description for the image from the user and change the spaces to “%20″
echo “Enter a discription”
read DES1
DES=`echo $DES1 | sed ‘s/ /\%20/g’`

#Get the keywords for the image from the user and change the spaces to “%20″
echo “Enter keywords (separated by spaces)”
read KEY1
KEY=`echo $KEY1 | sed ‘s/ /\%20/g’`

if [ -z "$FI" ]; then

UNIQUE_ID=$FIUP
#echo “Choose the NUMBER value for the album you want”
#curl -s -F control=phase_2 -F unique_ID=$UNIQUE_ID $URL | awk ‘/name=”album”/{disp=1} {if (disp==1) print} /<\/select>/{disp=0}’ | grep ‘value=”[0-9]“‘ | sed ‘s/<option//’ | sed ‘s/<\/option>//’ | sed ‘s/>//’
#read AL
curl -o /dev/null -d “control=phase_2&unique_ID=$UNIQUE_ID&album=$AL&title=$TITLE&caption=$DES&keywords=$KEY&blaa=continue” $URL
exit 0
else

# If the image is from a URL
UNIQUE_ID=$URLUP
#echo “Choose the NUMBER value for the album you want”
#curl -s -F control=phase_2 -F unique_ID=$UNIQUE_ID $URL | awk ‘/name=”album”/{disp=1} {if (disp==1) print} /<\/select>/{disp=0}’ | grep ‘value=”[0-9]“‘ | sed ‘s/<option//’ | sed ‘s/<\/option>//’ | sed ‘s/>//’
#read AL
curl -o /dev/null -d “control=phase_2&unique_ID=$UNIQUE_ID&album=$AL&title=$TITLE&caption=$DES&keywords=$KEY&blaa=continue” $URL
exit 0
fi

If there are any questions you can pretty much read the Shell Script Sundays column and figure out everything you need to know. Now that the upload script works, and tries to take a screenshot with scrot, the next step is a check to see if scrot exists, if it doesn’t a check for import, if not an error message.

It really does amaze me at the capabilities of the shell. Especially how mashable it is and how you can combine it with pretty much anything, this script is a great example of combining the power of the shell with the intrawebs. Well, I hoped you learned something, and as always if you have any questions, you know where the comment box is.

- Owen.