Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 27th, 2010  |  syntax: Bash  |  size: 1.64 KB  |  views: 483  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. #Change status of IM accounts on N900
  3. LIST="haze/yahoo/your_account
  4. haze/aim/your_account"
  5.  
  6. modify() {
  7.     ACCOUNT=$1
  8.     STATE=$2
  9.     echo -n "setting account to $STATE: "
  10.     /usr/bin/mc-tool request $ACCOUNT $STATE
  11.     if [ $? = 0 ]; then
  12.         echo "[OK]"
  13.     else
  14.         echo "[FAIL]"
  15.         exit 1
  16.     fi
  17.     exit 0
  18. }
  19.  
  20. choose() {
  21.     ACCOUNT=$1
  22.     echo "[1] online
  23. [2] offline"
  24.     echo -n "select state: "
  25.     read STATE
  26.     if [ "$STATE" = "1" ]; then
  27.         modify $ACCOUNT "available"
  28.     elif [ "$STATE" = "2" ]; then
  29.         modify $ACCOUNT "offline"
  30.     else
  31.         echo "incorrect choice"
  32.         exit 1
  33.     fi
  34. }
  35.  
  36. echo "[1] your_account - yahooIM
  37. [2] your_acount - AIM
  38. [2] ALL ACCOUNTS - show status
  39. [3] ALL ACCOUNTS - online
  40. [4] ALL ACCOUNTS - offline"
  41.  
  42. echo -n "select account: "
  43. read r
  44.  
  45. if [ "$r" = "1" ]; then
  46.     choose "haze/yahoo/your_account"
  47.  
  48. elif [ "$r" = "2" ]; then
  49.     choose "haze/aim/your_account"
  50.  
  51. elif [ "$r" = "2" ]; then
  52.     echo "showing status of all accounts"
  53.     for each in $LIST; do
  54.         /usr/bin/mc-tool show $each
  55.     done
  56.  
  57. elif [ "$r" = "3" ]; then
  58.     for each in $LIST; do
  59.         echo -n "setting '$each' to online: "
  60.         /usr/bin/mc-tool request $each available
  61.         if [ $? = 0 ]; then
  62.             echo "[OK]"
  63.         else
  64.             echo "[FAIL]"
  65.         fi
  66.     done
  67. elif [ "$r" = "4" ]; then
  68.     for each in $LIST; do
  69.         echo -n "setting '$each' to offline: "
  70.         /usr/bin/mc-tool request $each offline
  71.         if [ $? = 0 ]; then
  72.             echo "[OK]"
  73.         else
  74.             echo "[FAIL]"
  75.         fi
  76.     done
  77. fi
clone this paste RAW Paste Data