bbs.ChinaUnix.net
首页 | 微博 | 新闻 | Linux | FreeBSD | AIX | Windows | 博客 | 论坛 | 存储 | 网络 | 人才 | Wiki | 资料 | 读书 | 手册 | 下载 | 空间 | 搜索
  免费注册 | 忘记密码 | 会员登录 | 搜索 | 帮助 


精华帖子 Shell/Web 下發送 MSN Alert/Message

  首页 » 论坛 » Shell »
[打印] [收藏] [本帖文本页] [推荐此主题给朋友]

MSN 通常是用來交談的, Liunx 下最有名的 MSN Client 當屬 gaim,
不過因為它是 GUI 的環境,要以 shell 來應用實在不容易
(如果你能用 shell 控制 mouse 點在那裏就可以做到,但你能嗎 ? ()

1. 安裝 tmsnc (http://tmsnc.sourceforge.net/download.html)
我的例子是用 0.1.1 版本,你可以找別的版本自己開發,或參考我的例子也可以
  1. $>wget http://unc.dl.sourceforge.net/sourceforge/tmsnc/tmsnc-0.1.1.tar.gz
  2. $>tar -zxvf tmsnc-0.1.1.tar.gz
  3. $>cd tmsnc-0.1.1
  4. # 看一下 Makefile , 裏面的 openssl 路徑是否符合你的環境
  5. $>make
  6. $>make install
  7. $>tmsnc   (啟動的樣子)
  8.       .........
  9.     .'------.' |
  10.    | .-----. | |
  11.    | |TMSNC| | |;.
  12.    |*`-----'.|.' `;
  13.    `---------' .;'
  14.   .''''////////;'
  15. / ######### /;/    The
  16. / ######### //   textbased
  17. `-----------'   alternative!

  18. Login: abel@twnic.net.tw
  19. Your login-address is abel@twnic.net.tw
  20. Enter password:
复制代码

2.TMSNC 的指令說明
  1. # tmsnc 的 command 說明 (Readme),如果你要完善你的功能,就要詳讀任何的說明
  2. Availible commands in TMSNC are:
  3. * help                      show a list of availible commands
  4. * clear                     clear the screen
  5. * nick <name>               set your nickname to <name>
  6. * status <string>           where <string> is online, busy, brb,
  7. *                            away, phone, lunch or hidden
  8. * quit                      logout from server and quit TMSNC

  9. * add <address>             add <address> to the contact-list
  10. * block <address>           prevent <address> from obtaining your status
  11. * unblock <address>         reverse the block
  12. * remove <address>          remove <address> from contact-list
  13. * window <n> or TAB         change current window to <n>
  14. * window close or F7        close current window and conversation
  15. * chat <address> or Enter   start a new conversation with <address>
复制代码

由以上我們可以知道, tmsnc 我們巳經裝好了,所以就可以來做 shell 發送 msn 的工作了!
用 shell 來發,最好的工具是 expect , 這個工具的說明,你可以在 man page 中找到詳細
解說

3.
3.1
範例一(簡單版):
  1. #!/usr/bin/expect
  2. # filename=send.exp
  3. log_file ./exp.log
  4. spawn tmsnc -l 你申請的MSN帳號
  5. expect "Enter password:"
  6. send "你的密碼\r"
  7. expect -re ".* can't control me*"
  8. sleep 5

  9. send "/chat [lindex $argv 0]\n"
  10. expect -re ".*!.*"
  11. sleep 1
  12. send "Now: [exec date]\n"
  13. sleep 1
  14. send "[lindex $argv 1]\n"
  15. sleep 3
  16. send "/window close\r"
  17. send "/quit\r"
复制代码


用法:
  1. #請注意, MSN訊息需為 UTF-8 encoding
  2. $>./send.exp MSN連絡人 MSN訊息
复制代码


3.1
範例二(稍複雜版):

[code]
#!/usr/bin/expect
# log file , for debug
log_file ./exp.log
#設定訊息路經
set workdir "/www/htdocs/html/msn/msg"
# -l 指定 MSN contact, 你可以 tmsnc -h 來了解參數
spawn tmsnc -l 你申請的MSN帳號
sleep 1
# 出現 password 時,送出密碼
expect "Enter password:"
send "你的密碼\r"
sleep 1
# 出現 control me 時,表示 tmsnc 載入完成
expect -re ".* can't control me*"
sleep 3
# 無限迴圈,讀取訊息檔
while {1} {
        sleep 1
        #取得 訊息檔中第一行,我個人的定義是 MSN addr
        set msn_addr [ exec cat $workdir/msg.utf8 |  head -1 ]
        #如果

mysql_alert.sh 發送的例子

cu-reply.gif
__________________________________
no pm,no answer



Shell/Web 下發送 MSN Alert/Message

参考!



Shell/Web 下發送 MSN Alert/Message

非常不错,值得学习。
__________________________________
孤剑寒芒,流光化秋雨
独行万里,为有破天时
创意未来,豪气塞寰宇
业经风雨,微笑顾心志

我的BLOG开通了!!!



Shell/Web 下發送 MSN Alert/Message

提示: 作者被禁止或删除 内容自动屏蔽



Shell/Web 下發送 MSN Alert/Message

Makefile 中的
LIB= -L/usr/lib -lssl -lcrypto -lpanel -lncurses
INC= -I/usr/local/include -I/usr/local/ssl/include -I/usr/include/ssl

改成
  1. LIB= -L/usr/lib -L/usr/local/openssl/lib -lssl -lcrypto -lpanel -lncurses
  2. INC= -I/usr/local/include -I/usr/local/ssl/include -I/usr/include/ssl -I/usr/local/openssl/include
复制代码


不然你就在裝一次 openssl 在 /usr 下,就不用改 makefile
__________________________________
no pm,no answer



Shell/Web 下發送 MSN Alert/Message

要是能发短消息到手机就好了,呵呵
不过发到msn也是不错的,谢谢你的分享!!



Shell/Web 下發送 MSN Alert/Message



QUOTE:
原帖由 "glider126" 发表:
要是能发短消息到手机就好了,呵呵
不过发到msn也是不错的,谢谢你的分享!!


發到手機簡單的很,你只要買點數就好了
廠商會給你 帳號/密碼及相關 api
__________________________________
no pm,no answer



Shell/Web 下發送 MSN Alert/Message

有心人啊,顶下先!



Shell/Web 下發送 MSN Alert/Message

最好还是装新版的openssl吧,编译一定没有问题.

每次看abel兄的文章总有大的收获!非常感谢你.
__________________________________


MySite:
http://www.joecen.com



有没有办法获得 contact list?


  首页 » 论坛 » Shell »
Copyright © 2001-2010 ChinaUnix.net All Rights Reserved     联系我们:

感谢所有关心和支持过ChinaUnix的朋友们    转载本站内容请注明原作者名及出处

京ICP证041476号


清除 Cookies - ChinaUnix - Archiver - WAP - TOP