Google URL shortener script

Maybe it’s no longer working

 bash | 
 
 copy code |
?

01
#!/bin/bash
02
# Google url shortener bash script
03
# For information about the app:
04
# http://ggl-shortener.appspot.com/instructions/
05
06
07
app='http://ggl-shortener.appspot.com/?url='
08
url="$1"
09
10
protocol=`echo "$1" | sed -e "/^http:///g"`
11
12
if [ -z "$1" ]; then
13
 echo -e "you need to pass the url through an argument";
14
 echo -e "e.g. `basename $0` http://url";
15
else
16
 if [ ! "$protocol" ]; then
17
 curl -s "$app$url" | sed -e 's/{"short_url":"//' -e 's/"}/n/g' 
18
 else
19
 repl=`echo "$1" | sed -e 's/^/http:///g'`
20
 curl -s "$app$repl" | sed -e 's/{"short_url":"//' -e 's/{"error_message":"Bad request/error: bad r威而鋼
21
equest/' -e 's/"}/n/g'