[App_rpt-users] Twitter Script

Paul M. Nannery kc2vrj at gmail.com
Thu Aug 23 01:36:29 UTC 2012


#!/bin/bash

#-----

# tweet_conn.sh

#

# This script will tweet the current connection on an Allstar Node.

#

# Place this script in your /usr/local/bin directory and make sure

# it is owned by the user that runs asterisk. Also, make sure the

# script is executable.

#

# You must insert as line in your /etc/asterisk/rpt.conf file that

# looks like this:

# connpgm=/usr/local/bin/tweet_conn.sh

# Then restart asterisk.

# Also go to supertweet.net and sign up for and account this is #the
username and password needed for this script.

#-----

case ${2:0:1} in

4) # IRLP Nodes begin with 4

  nodeno=${2:1} # Strip the leading 4

  case ${nodeno:0:1} in

  0) # Experimental Nodes beginwith 0

     systype="IRLP Experimental"

     ;;

 

  9) # Reflectors begin with 9

     systype="IRLP Reflector"

     ;;

 

  *) # User Nodes begin with 1-8

     systype="IRLP Node"

     ;;

  esac

  ;;

 

3) # EchoLink Node begin with 3

  nodeno=${2:1} # Strip the leading 3

  node1=$2 # for dis con

  echo "asterisk -rx \"rpt fun $1 *1$2\" " >> /etc/asterisk/backup/echo

  systype="EchoLink Node"

  ;;

 

2) # Allstar node begin with 2

  nodeno=$2 # The node number is OK

  systype="AllStar Node"

  ;;

 

*) # Default - Unknow connection type

  nodeno=$2 # The raw "them"

  systype="web/phone"

  ;;

esac

 

# Tweet it

curl -u username:password -d status="call sign-$1 connected

from $systype $nodeno" http://api.supertweet.net/1/statuses/update.xml

&>/dev/null &

 

exit 0

 

 

 

I used the BASH substring function. ${var:start[:len]} where var is

the variable name, start is the place in the string where processing

is to start (0 base) and len is the number of characters to be used.

If len is not specified, is is taken to be from the start to the end

of the string. As shown in the code, ${2:0:1} will return the first

character of the string; therefore, if $2 == 43340, then ${2:0:1} will

return 4 (the first character of the string). ${2:1} will return 3340

(everything after the first character). The case statement makes it

very easy to have a number of choices where only one choice runs.

Either that or string together a lot of if..elif..else..fi rubbish.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.keekles.org/pipermail/app_rpt-users/attachments/20120822/1b1edee0/attachment.html>


More information about the App_rpt-users mailing list