Linux Blog

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.

KDE Wall Paper Contest

Filed under: General Linux — TheLinuxBlog.com at 8:56 am on Thursday, August 2, 2007

A wall paper contest was posted this morning on Digg and many other blogs. The contest is simple, upload wall papers that you created and you have the possibility of getting them included in the next release of KDE.

After viewing the blog and homepage of the link submitted in the article, I was a bit skeptical as to whether this was just a scheme for a blogger to get some publicity, so I did some research. Turns out that Riccardo Laconelli is not listed in the main credits for the KDE project, but is listed in the KDE lists [lists.kde.org]. It also seems as if he is the developer of the Oxygen theme and has committed various icons to the KDE project.

Should you participate in this contest?

I believe if you have any artistic skills that you should design a wall paper and submit it to the competition. For your efforts you may have your wall paper included one of the most popular window managers and it will make you feel good for contributing. If you enter the competition and your entries are not specific to KDE I urge you to also post your wallpapers on your own site/blog/photo gallery and other Linux wall paper sites. Some people like to be able to use wall papers on other window managers. If I had any artistic skills I would most defiantly be entering this competition myself.

KDE Wallpaper Contest is [http://pd.ruphy.org/]