GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   free goo.gl script for you linux users (https://gfy.com/showthread.php?t=990612)

fris 10-04-2010 05:12 PM

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

:thumbsup

V_RocKs 10-04-2010 06:18 PM

Always giving back to the community. Its funny how many detractors a guy can have when he is making things easier for the entire community.

Barry-xlovecam 10-04-2010 07:06 PM

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 :thumbsup

fris 10-04-2010 08:00 PM

Quote:

Originally Posted by Barry-xlovecam (Post 17570945)
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 :thumbsup

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

:thumbsup

signupdamnit 10-04-2010 08:01 PM

Nice. :thumbsup

GetSCORECash 10-04-2010 08:41 PM

Thanks!!!!

bDok 10-04-2010 10:44 PM

nice. works of course just fine on os x too. Dropped her in /usr/local/bin/

thanx.
http://goo.gl/EQve

fris 10-04-2010 11:10 PM

Quote:

Originally Posted by bDok (Post 17571622)
nice. works of course just fine on os x too. Dropped her in /usr/local/bin/

thanx.
http://goo.gl/EQve

ya figured it would work fine on osx ;)


All times are GMT -7. The time now is 01:32 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123