1*906afcb8SAndy Fiddaman#!/usr/bin/ksh93 2*906afcb8SAndy Fiddaman 3*906afcb8SAndy Fiddaman# 4*906afcb8SAndy Fiddaman# CDDL HEADER START 5*906afcb8SAndy Fiddaman# 6*906afcb8SAndy Fiddaman# The contents of this file are subject to the terms of the 7*906afcb8SAndy Fiddaman# Common Development and Distribution License (the "License"). 8*906afcb8SAndy Fiddaman# You may not use this file except in compliance with the License. 9*906afcb8SAndy Fiddaman# 10*906afcb8SAndy Fiddaman# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*906afcb8SAndy Fiddaman# or http://www.opensolaris.org/os/licensing. 12*906afcb8SAndy Fiddaman# See the License for the specific language governing permissions 13*906afcb8SAndy Fiddaman# and limitations under the License. 14*906afcb8SAndy Fiddaman# 15*906afcb8SAndy Fiddaman# When distributing Covered Code, include this CDDL HEADER in each 16*906afcb8SAndy Fiddaman# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*906afcb8SAndy Fiddaman# If applicable, add the following below this CDDL HEADER, with the 18*906afcb8SAndy Fiddaman# fields enclosed by brackets "[]" replaced with your own identifying 19*906afcb8SAndy Fiddaman# information: Portions Copyright [yyyy] [name of copyright owner] 20*906afcb8SAndy Fiddaman# 21*906afcb8SAndy Fiddaman# CDDL HEADER END 22*906afcb8SAndy Fiddaman# 23*906afcb8SAndy Fiddaman 24*906afcb8SAndy Fiddaman# 25*906afcb8SAndy Fiddaman# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 26*906afcb8SAndy Fiddaman# 27*906afcb8SAndy Fiddaman 28*906afcb8SAndy Fiddaman# Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant 29*906afcb8SAndy Fiddamanexport PATH=/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin 30*906afcb8SAndy Fiddaman 31*906afcb8SAndy Fiddaman# Make sure all math stuff runs in the "C" locale to avoid problems 32*906afcb8SAndy Fiddaman# with alternative # radix point representations (e.g. ',' instead of 33*906afcb8SAndy Fiddaman# '.' in de_DE.*-locales). This needs to be set _before_ any 34*906afcb8SAndy Fiddaman# floating-point constants are defined in this script). 35*906afcb8SAndy Fiddamanif [[ "${LC_ALL}" != "" ]] ; then 36*906afcb8SAndy Fiddaman export \ 37*906afcb8SAndy Fiddaman LC_MONETARY="${LC_ALL}" \ 38*906afcb8SAndy Fiddaman LC_MESSAGES="${LC_ALL}" \ 39*906afcb8SAndy Fiddaman LC_COLLATE="${LC_ALL}" \ 40*906afcb8SAndy Fiddaman LC_CTYPE="${LC_ALL}" 41*906afcb8SAndy Fiddaman unset LC_ALL 42*906afcb8SAndy Fiddamanfi 43*906afcb8SAndy Fiddamanexport LC_NUMERIC=C 44*906afcb8SAndy Fiddaman 45*906afcb8SAndy Fiddamanfunction fatal_error 46*906afcb8SAndy Fiddaman{ 47*906afcb8SAndy Fiddaman print -u2 "${progname}: $*" 48*906afcb8SAndy Fiddaman exit 1 49*906afcb8SAndy Fiddaman} 50*906afcb8SAndy Fiddaman 51*906afcb8SAndy Fiddamanfunction encode_x_www_form_urlencoded 52*906afcb8SAndy Fiddaman{ 53*906afcb8SAndy Fiddaman nameref formdata=$1 54*906afcb8SAndy Fiddaman nameref content="formdata.content" 55*906afcb8SAndy Fiddaman integer numformelements=${#formdata.form[*]} 56*906afcb8SAndy Fiddaman integer i j 57*906afcb8SAndy Fiddaman 58*906afcb8SAndy Fiddaman content="" 59*906afcb8SAndy Fiddaman 60*906afcb8SAndy Fiddaman for (( i=0 ; i < numformelements ; i++ )) ; do 61*906afcb8SAndy Fiddaman nameref element="formdata.form[${i}]" 62*906afcb8SAndy Fiddaman typeset data="${element.data}" 63*906afcb8SAndy Fiddaman integer datalen="${#data}" 64*906afcb8SAndy Fiddaman typeset c 65*906afcb8SAndy Fiddaman 66*906afcb8SAndy Fiddaman [[ "$content" != "" ]] && content+="&" 67*906afcb8SAndy Fiddaman 68*906afcb8SAndy Fiddaman content+="${element.name}=" 69*906afcb8SAndy Fiddaman 70*906afcb8SAndy Fiddaman for ((j=0 ; j < datalen ; j++)) ; do 71*906afcb8SAndy Fiddaman c="${data:j:1}" 72*906afcb8SAndy Fiddaman case "$c" in 73*906afcb8SAndy Fiddaman ' ') c="+" ;; 74*906afcb8SAndy Fiddaman '!') c="%21" ;; 75*906afcb8SAndy Fiddaman '*') c="%2A" ;; 76*906afcb8SAndy Fiddaman "'") c="%27" ;; 77*906afcb8SAndy Fiddaman '(') c="%28" ;; 78*906afcb8SAndy Fiddaman ')') c="%29" ;; 79*906afcb8SAndy Fiddaman ';') c="%3B" ;; 80*906afcb8SAndy Fiddaman ':') c="%3A" ;; 81*906afcb8SAndy Fiddaman '@') c="%40" ;; 82*906afcb8SAndy Fiddaman '&') c="%26" ;; 83*906afcb8SAndy Fiddaman '=') c="%3D" ;; 84*906afcb8SAndy Fiddaman '+') c="%2B" ;; 85*906afcb8SAndy Fiddaman '$') c="%24" ;; 86*906afcb8SAndy Fiddaman ',') c="%2C" ;; 87*906afcb8SAndy Fiddaman '/') c="%2F" ;; 88*906afcb8SAndy Fiddaman '?') c="%3F" ;; 89*906afcb8SAndy Fiddaman '%') c="%25" ;; 90*906afcb8SAndy Fiddaman '#') c="%23" ;; 91*906afcb8SAndy Fiddaman '[') c="%5B" ;; 92*906afcb8SAndy Fiddaman '\') c="%5C" ;; # we need this to avoid the '\'-quoting hell 93*906afcb8SAndy Fiddaman ']') c="%5D" ;; 94*906afcb8SAndy Fiddaman *) ;; 95*906afcb8SAndy Fiddaman esac 96*906afcb8SAndy Fiddaman content+="$c" 97*906afcb8SAndy Fiddaman done 98*906afcb8SAndy Fiddaman done 99*906afcb8SAndy Fiddaman 100*906afcb8SAndy Fiddaman formdata.content_length=${#content} 101*906afcb8SAndy Fiddaman 102*906afcb8SAndy Fiddaman return 0 103*906afcb8SAndy Fiddaman} 104*906afcb8SAndy Fiddaman 105*906afcb8SAndy Fiddaman# parse HTTP return code, cookies etc. 106*906afcb8SAndy Fiddamanfunction parse_http_response 107*906afcb8SAndy Fiddaman{ 108*906afcb8SAndy Fiddaman nameref response="$1" 109*906afcb8SAndy Fiddaman typeset h statuscode statusmsg i 110*906afcb8SAndy Fiddaman 111*906afcb8SAndy Fiddaman # we use '\r' as additional IFS to filter the final '\r' 112*906afcb8SAndy Fiddaman IFS=$' \t\r' read -r h statuscode statusmsg # read HTTP/1.[01] <code> 113*906afcb8SAndy Fiddaman [[ "$h" != ~(Eil)HTTP/.* ]] && { print -u2 -f $"%s: HTTP/ header missing\n" "$0" ; return 1 ; } 114*906afcb8SAndy Fiddaman [[ "$statuscode" != ~(Elr)[0-9]* ]] && { print -u2 -f $"%s: invalid status code\n" "$0" ; return 1 ; } 115*906afcb8SAndy Fiddaman response.statuscode="$statuscode" 116*906afcb8SAndy Fiddaman response.statusmsg="$statusmsg" 117*906afcb8SAndy Fiddaman 118*906afcb8SAndy Fiddaman # skip remaining headers 119*906afcb8SAndy Fiddaman while IFS='' read -r i ; do 120*906afcb8SAndy Fiddaman [[ "$i" == $'\r' ]] && break 121*906afcb8SAndy Fiddaman 122*906afcb8SAndy Fiddaman # strip '\r' at the end 123*906afcb8SAndy Fiddaman i="${i/~(Er)$'\r'/}" 124*906afcb8SAndy Fiddaman 125*906afcb8SAndy Fiddaman case "$i" in 126*906afcb8SAndy Fiddaman ~(Eli)Content-Type:.*) 127*906afcb8SAndy Fiddaman response.content_type="${i/~(El).*:[[:blank:]]*/}" 128*906afcb8SAndy Fiddaman ;; 129*906afcb8SAndy Fiddaman ~(Eli)Content-Length:[[:blank:]]*[0-9]*) 130*906afcb8SAndy Fiddaman integer response.content_length="${i/~(El).*:[[:blank:]]*/}" 131*906afcb8SAndy Fiddaman ;; 132*906afcb8SAndy Fiddaman ~(Eli)Transfer-Encoding:.*) 133*906afcb8SAndy Fiddaman response.transfer_encoding="${i/~(El).*:[[:blank:]]*/}" 134*906afcb8SAndy Fiddaman ;; 135*906afcb8SAndy Fiddaman esac 136*906afcb8SAndy Fiddaman done 137*906afcb8SAndy Fiddaman 138*906afcb8SAndy Fiddaman return 0 139*906afcb8SAndy Fiddaman} 140*906afcb8SAndy Fiddaman 141*906afcb8SAndy Fiddamanfunction cat_http_body 142*906afcb8SAndy Fiddaman{ 143*906afcb8SAndy Fiddaman typeset emode="$1" 144*906afcb8SAndy Fiddaman typeset hexchunksize="0" 145*906afcb8SAndy Fiddaman integer chunksize=0 146*906afcb8SAndy Fiddaman 147*906afcb8SAndy Fiddaman if [[ "${emode}" == "chunked" ]] ; then 148*906afcb8SAndy Fiddaman while IFS=$'\r' read hexchunksize && 149*906afcb8SAndy Fiddaman [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] && 150*906afcb8SAndy Fiddaman (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) && (( chunksize > 0 )) ; do 151*906afcb8SAndy Fiddaman dd bs=1 count="${chunksize}" 2>/dev/null 152*906afcb8SAndy Fiddaman done 153*906afcb8SAndy Fiddaman else 154*906afcb8SAndy Fiddaman cat 155*906afcb8SAndy Fiddaman fi 156*906afcb8SAndy Fiddaman 157*906afcb8SAndy Fiddaman return 0 158*906afcb8SAndy Fiddaman} 159*906afcb8SAndy Fiddaman 160*906afcb8SAndy Fiddamanfunction encode_http_basic_auth 161*906afcb8SAndy Fiddaman{ 162*906afcb8SAndy Fiddaman typeset user="$1" 163*906afcb8SAndy Fiddaman typeset passwd="$2" 164*906afcb8SAndy Fiddaman typeset s 165*906afcb8SAndy Fiddaman integer s_len 166*906afcb8SAndy Fiddaman typeset -b base64var 167*906afcb8SAndy Fiddaman 168*906afcb8SAndy Fiddaman # ksh93 binary variables use base64 encoding, the same as the 169*906afcb8SAndy Fiddaman # HTTP basic authentification. We only have to read the 170*906afcb8SAndy Fiddaman # plaintext user:passwd string into the binary variable "base64var" 171*906afcb8SAndy Fiddaman # and then print this variable as ASCII. 172*906afcb8SAndy Fiddaman s="${user}:${passwd}" 173*906afcb8SAndy Fiddaman s_len="${#s}" 174*906afcb8SAndy Fiddaman print -n "${s}" | read -N${s_len} base64var 175*906afcb8SAndy Fiddaman 176*906afcb8SAndy Fiddaman print -- "${base64var}" # print ASCII (base64) representation of binary var 177*906afcb8SAndy Fiddaman 178*906afcb8SAndy Fiddaman return 0 179*906afcb8SAndy Fiddaman} 180*906afcb8SAndy Fiddaman 181*906afcb8SAndy Fiddamanfunction put_twitter_message 182*906afcb8SAndy Fiddaman{ 183*906afcb8SAndy Fiddaman [[ "$SHTWITTER_USER" == "" ]] && { print -u2 -f $"%s: SHTWITTER_USER not set.\n" "$0" ; return 1 ; } 184*906afcb8SAndy Fiddaman [[ "$SHTWITTER_PASSWD" == "" ]] && { print -u2 -f $"%s: SHTWITTER_PASSWD not set.\n" "$0" ; return 1 ; } 185*906afcb8SAndy Fiddaman 186*906afcb8SAndy Fiddaman (( $# != 1 )) && { print -u2 -f $"%s: Wrong number of arguments.\n" "$0" ; return 1 ; } 187*906afcb8SAndy Fiddaman 188*906afcb8SAndy Fiddaman # site setup 189*906afcb8SAndy Fiddaman typeset url_host="twitter.com" 190*906afcb8SAndy Fiddaman typeset url_path="/statuses/update.xml" 191*906afcb8SAndy Fiddaman typeset url="http://${url_host}${url_path}" 192*906afcb8SAndy Fiddaman integer netfd # http stream number 193*906afcb8SAndy Fiddaman typeset msgtext="$1" 194*906afcb8SAndy Fiddaman compound httpresponse # http response 195*906afcb8SAndy Fiddaman 196*906afcb8SAndy Fiddaman # argument for "encode_x_www_form_urlencoded" 197*906afcb8SAndy Fiddaman compound urlform=( 198*906afcb8SAndy Fiddaman # input 199*906afcb8SAndy Fiddaman compound -a form=( 200*906afcb8SAndy Fiddaman ( name="status" data="${msgtext}" ) 201*906afcb8SAndy Fiddaman ) 202*906afcb8SAndy Fiddaman # output 203*906afcb8SAndy Fiddaman typeset content 204*906afcb8SAndy Fiddaman integer content_length 205*906afcb8SAndy Fiddaman ) 206*906afcb8SAndy Fiddaman 207*906afcb8SAndy Fiddaman typeset request="" 208*906afcb8SAndy Fiddaman typeset content="" 209*906afcb8SAndy Fiddaman 210*906afcb8SAndy Fiddaman encode_x_www_form_urlencoded urlform 211*906afcb8SAndy Fiddaman 212*906afcb8SAndy Fiddaman content="${urlform.content}" 213*906afcb8SAndy Fiddaman 214*906afcb8SAndy Fiddaman request="POST ${url_path} HTTP/1.1\r\n" 215*906afcb8SAndy Fiddaman request+="Host: ${url_host}\r\n" 216*906afcb8SAndy Fiddaman request+="Authorization: Basic ${ encode_http_basic_auth "${SHTWITTER_USER}" "${SHTWITTER_PASSWD}" ; }\r\n" 217*906afcb8SAndy Fiddaman request+="User-Agent: ${http_user_agent}\r\n" 218*906afcb8SAndy Fiddaman request+="Connection: close\r\n" 219*906afcb8SAndy Fiddaman request+="Content-Type: application/x-www-form-urlencoded\r\n" 220*906afcb8SAndy Fiddaman request+="Content-Length: $(( urlform.content_length ))\r\n" 221*906afcb8SAndy Fiddaman 222*906afcb8SAndy Fiddaman redirect {netfd}<> "/dev/tcp/${url_host}/80" 223*906afcb8SAndy Fiddaman (( $? != 0 )) && { print -u2 -f "%s: Could not open connection to %s\n." "$0" "${url_host}" ; return 1 ; } 224*906afcb8SAndy Fiddaman 225*906afcb8SAndy Fiddaman # send http post 226*906afcb8SAndy Fiddaman { 227*906afcb8SAndy Fiddaman print -n -- "${request}\r\n" 228*906afcb8SAndy Fiddaman print -n -- "${content}\r\n" 229*906afcb8SAndy Fiddaman } >&${netfd} 230*906afcb8SAndy Fiddaman 231*906afcb8SAndy Fiddaman # process reply 232*906afcb8SAndy Fiddaman parse_http_response httpresponse <&${netfd} 233*906afcb8SAndy Fiddaman response="${ cat_http_body "${httpresponse.transfer_encoding}" <&${netfd} ; }" 234*906afcb8SAndy Fiddaman 235*906afcb8SAndy Fiddaman # close connection 236*906afcb8SAndy Fiddaman redirect {netfd}<&- 237*906afcb8SAndy Fiddaman 238*906afcb8SAndy Fiddaman printf $"twitter response was (%s,%s): %s\n" "${httpresponse.statuscode}" "${httpresponse.statusmsg}" "${response}" 239*906afcb8SAndy Fiddaman 240*906afcb8SAndy Fiddaman if (( httpresponse.statuscode >= 200 && httpresponse.statuscode <= 299 )) ; then 241*906afcb8SAndy Fiddaman return 0 242*906afcb8SAndy Fiddaman else 243*906afcb8SAndy Fiddaman return 1 244*906afcb8SAndy Fiddaman fi 245*906afcb8SAndy Fiddaman 246*906afcb8SAndy Fiddaman # not reached 247*906afcb8SAndy Fiddaman} 248*906afcb8SAndy Fiddaman 249*906afcb8SAndy Fiddamanfunction verify_twitter_credentials 250*906afcb8SAndy Fiddaman{ 251*906afcb8SAndy Fiddaman [[ "$SHTWITTER_USER" == "" ]] && { print -u2 -f $"%s: SHTWITTER_USER not set.\n" "$0" ; return 1 ; } 252*906afcb8SAndy Fiddaman [[ "$SHTWITTER_PASSWD" == "" ]] && { print -u2 -f $"%s: SHTWITTER_PASSWD not set.\n" "$0" ; return 1 ; } 253*906afcb8SAndy Fiddaman 254*906afcb8SAndy Fiddaman (( $# != 0 )) && { print -u2 -f $"%s: Wrong number of arguments.\n" "$0" ; return 1 ; } 255*906afcb8SAndy Fiddaman 256*906afcb8SAndy Fiddaman # site setup 257*906afcb8SAndy Fiddaman typeset url_host="twitter.com" 258*906afcb8SAndy Fiddaman typeset url_path="/account/verify_credentials.xml" 259*906afcb8SAndy Fiddaman typeset url="http://${url_host}${url_path}" 260*906afcb8SAndy Fiddaman integer netfd # http stream number 261*906afcb8SAndy Fiddaman compound httpresponse # http response 262*906afcb8SAndy Fiddaman 263*906afcb8SAndy Fiddaman typeset request="" 264*906afcb8SAndy Fiddaman 265*906afcb8SAndy Fiddaman request="POST ${url_path} HTTP/1.1\r\n" 266*906afcb8SAndy Fiddaman request+="Host: ${url_host}\r\n" 267*906afcb8SAndy Fiddaman request+="Authorization: Basic ${ encode_http_basic_auth "${SHTWITTER_USER}" "${SHTWITTER_PASSWD}" ; }\r\n" 268*906afcb8SAndy Fiddaman request+="User-Agent: ${http_user_agent}\r\n" 269*906afcb8SAndy Fiddaman request+="Connection: close\r\n" 270*906afcb8SAndy Fiddaman request+="Content-Type: application/x-www-form-urlencoded\r\n" 271*906afcb8SAndy Fiddaman request+="Content-Length: 0\r\n" # dummy 272*906afcb8SAndy Fiddaman 273*906afcb8SAndy Fiddaman redirect {netfd}<> "/dev/tcp/${url_host}/80" 274*906afcb8SAndy Fiddaman (( $? != 0 )) && { print -u2 -f $"%s: Could not open connection to %s.\n" "$0" "${url_host}" ; return 1 ; } 275*906afcb8SAndy Fiddaman 276*906afcb8SAndy Fiddaman # send http post 277*906afcb8SAndy Fiddaman { 278*906afcb8SAndy Fiddaman print -n -- "${request}\r\n" 279*906afcb8SAndy Fiddaman } >&${netfd} 280*906afcb8SAndy Fiddaman 281*906afcb8SAndy Fiddaman # process reply 282*906afcb8SAndy Fiddaman parse_http_response httpresponse <&${netfd} 283*906afcb8SAndy Fiddaman response="${ cat_http_body "${httpresponse.transfer_encoding}" <&${netfd} ; }" 284*906afcb8SAndy Fiddaman 285*906afcb8SAndy Fiddaman # close connection 286*906afcb8SAndy Fiddaman redirect {netfd}<&- 287*906afcb8SAndy Fiddaman 288*906afcb8SAndy Fiddaman printf $"twitter response was (%s,%s): %s\n" "${httpresponse.statuscode}" "${httpresponse.statusmsg}" "${response}" 289*906afcb8SAndy Fiddaman 290*906afcb8SAndy Fiddaman if (( httpresponse.statuscode >= 200 && httpresponse.statuscode <= 299 )) ; then 291*906afcb8SAndy Fiddaman return 0 292*906afcb8SAndy Fiddaman else 293*906afcb8SAndy Fiddaman return 1 294*906afcb8SAndy Fiddaman fi 295*906afcb8SAndy Fiddaman 296*906afcb8SAndy Fiddaman # not reached 297*906afcb8SAndy Fiddaman} 298*906afcb8SAndy Fiddaman 299*906afcb8SAndy Fiddamanfunction usage 300*906afcb8SAndy Fiddaman{ 301*906afcb8SAndy Fiddaman OPTIND=0 302*906afcb8SAndy Fiddaman getopts -a "${progname}" "${shtwitter_usage}" OPT '-?' 303*906afcb8SAndy Fiddaman exit 2 304*906afcb8SAndy Fiddaman} 305*906afcb8SAndy Fiddaman 306*906afcb8SAndy Fiddaman# program start 307*906afcb8SAndy Fiddamanbuiltin basename 308*906afcb8SAndy Fiddamanbuiltin cat 309*906afcb8SAndy Fiddamanbuiltin date 310*906afcb8SAndy Fiddamanbuiltin uname 311*906afcb8SAndy Fiddaman 312*906afcb8SAndy Fiddamantypeset progname="${ basename "${0}" ; }" 313*906afcb8SAndy Fiddaman 314*906afcb8SAndy Fiddaman# HTTP protocol client identifer 315*906afcb8SAndy Fiddamantypeset -r http_user_agent="shtwitter/ksh93 (2010-03-27; ${ uname -s -r -p ; })" 316*906afcb8SAndy Fiddaman 317*906afcb8SAndy Fiddamantypeset -r shtwitter_usage=$'+ 318*906afcb8SAndy Fiddaman[-?\n@(#)\$Id: shtwitter (Roland Mainz) 2010-03-27 \$\n] 319*906afcb8SAndy Fiddaman[-author?Roland Mainz <roland.mainz@nrubsig.org>] 320*906afcb8SAndy Fiddaman[+NAME?shtwitter - read/write text data to internet clipboards] 321*906afcb8SAndy Fiddaman[+DESCRIPTION?\bshtwitter\b is a small utility which can read and write text 322*906afcb8SAndy Fiddaman to the twitter.com microblogging site.] 323*906afcb8SAndy Fiddaman[+?The first arg \bmethod\b describes one of the methods, "update" posts a 324*906afcb8SAndy Fiddaman text message to the users twitter blog, returning the raw response 325*906afcb8SAndy Fiddaman message from the twitter server.] 326*906afcb8SAndy Fiddaman[+?The second arg \bstring\b contains the string data which should be 327*906afcb8SAndy Fiddaman stored on twitter.com.] 328*906afcb8SAndy Fiddaman 329*906afcb8SAndy Fiddamanmethod [ string ] 330*906afcb8SAndy Fiddaman 331*906afcb8SAndy Fiddaman[+SEE ALSO?\bksh93\b(1), \brssread\b(1), \bshtinyurl\b(1), http://www.twitter.com] 332*906afcb8SAndy Fiddaman' 333*906afcb8SAndy Fiddaman 334*906afcb8SAndy Fiddamanwhile getopts -a "${progname}" "${shtwitter_usage}" OPT ; do 335*906afcb8SAndy Fiddaman# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|" 336*906afcb8SAndy Fiddaman case ${OPT} in 337*906afcb8SAndy Fiddaman *) usage ;; 338*906afcb8SAndy Fiddaman esac 339*906afcb8SAndy Fiddamandone 340*906afcb8SAndy Fiddamanshift $((OPTIND-1)) 341*906afcb8SAndy Fiddaman 342*906afcb8SAndy Fiddaman# expecting at least one more argument 343*906afcb8SAndy Fiddaman(($# >= 1)) || usage 344*906afcb8SAndy Fiddaman 345*906afcb8SAndy Fiddamantypeset method="$1" 346*906afcb8SAndy Fiddamanshift 347*906afcb8SAndy Fiddaman 348*906afcb8SAndy Fiddamancase "${method}" in 349*906afcb8SAndy Fiddaman update|blog) put_twitter_message "$@" ; exit $? ;; 350*906afcb8SAndy Fiddaman verify_credentials) verify_twitter_credentials "$@" ; exit $? ;; 351*906afcb8SAndy Fiddaman *) usage ;; 352*906afcb8SAndy Fiddamanesac 353*906afcb8SAndy Fiddaman 354*906afcb8SAndy Fiddamanfatal_error $"not reached." 355*906afcb8SAndy Fiddaman# EOF. 356