Snippet-171


stáhnout snippet
zobrazení: SyntaxHighlighter | GeSHi | Holý text
#!/bin/bash

clientLoginUrl="https://www.google.com/accounts/ClientLogin"
email=$2
password=$3
service=$4
tmpFile="/tmp/translator-toolkit-bug"

auth() {
    authResponse=$(curl "$clientLoginUrl" --data-urlencode Email="$email" --data-urlencode Passwd="$password" -d accountType=GOOGLE -d source=GTT-BUG -d service="$service")
    authToken="${authResponse##*=}"
}

check() {
    if [ "$1" == "auth" ] $$ [ -n "$2" ] && [ -n "$3" ] && [ -n "$4" ]
    then
        authentication=1
    elif [[ "$1" == http* ]]
    then
        request=1
    else
        echo "First authenticate   :  ./client.sh auth email@example.com password"
        echo "Then send a request  :  ./client.sh http://translate.google.com/toolkit/feeds/documents"
        exit 1
    fi
}

check

if [ -n "$authentication" ] && [ "$authentication" -eq 1 ]
then
    auth
    echo "$authToken" > "$tmpFile"
elif [ -n "$request" ] && [ "$request" -eq 1 ]
then
    curl --silent --verbose --header "Authorization: GoogleLogin auth=${authToken}" "$1"
else
    echo "omg wtf"
fi


bash 40 řádků | 2011-10-09 17:38:01