View Single Post
Old 10-04-2010, 08:00 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
Quote:
Originally Posted by Barry-xlovecam View Post
Works Good

Code:
$ ./gooShortURL.sh create http://pastebin.com/bx8zYRUV
./gooShortURL.sh: line 13: curl: command not found

$ sudo apt-get install curl
[sudo] password 

$ ./gooShortURL.sh create http://pastebin.com/bx8zYRUV
http://goo.gl/Nljx
$
Had to install curl

Try Link
should have added a curl check.

here is the updated code

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
;;
*)

if which curl >/dev/null; then 

echo "Usage: `basename $0` {create|decode}" >&2

else 
    echo "curl missing from your system, please install it";
fi 

exit 64
;;
esac
__________________
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