View Single Post
Old 10-04-2010, 05:12 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
free goo.gl script for you linux users

Was bored today, this is for you linux users that want to create and decode links using the goo.gl url shortener service.

Code:
#!//bin/bash

# goo.gl link creator and decoder

case "$1" in
create)

if [ $# -ne 2 ] 
then
 echo "url to shorten needed."
 exit
fi
curl -s -d "url=${2}" http://goo.gl/api/url | sed -n "s/.*:\"\([^\"]*\).*/\1/p";
;;

decode)

if [ $# -ne 2 ] 
then
 echo "url to decode needed"
 exit
fi

check=$(echo $2 | sed -n 's/.*\(http:\/\/goo.gl\/[A-Za-z0-9][A-Za-z0-9]*\).*/\1/p');

if [ -n "$(echo $check)" ]; then 
curl -sI $2 | sed -n 's/Location:.* //p';
else
echo "you must give a valid goo.gl link"
fi
;;
*)

echo "Usage: `basename $0` {create|decode}" >&2
exit 64
;;
esac
also posted it on pastebin

http://pastebin.com/bx8zYRUV

enjoy ;)

__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote