| 您的位置:首页 > 文档 > Shell > |
文章分类热门文章 |
expect使用一例创建:2005-10-26 00:49:42 作者:Unlinux 来自: http://www.Unlinux.com Using Expect to do it... 改一下ftp 成telnet ,與Prompt的地方..與你要做的事情就好了... 代码: #!/usr/local/bin/expect -- set send_slow {10 .1} eval spawn ftp 10.1.1.1 set timeout 10 expect { timeout { send_user "TIMEOUT:10.1.1.1 " exit 0; } "):" { send "apile " } "refused" { send_user "Connection Failed " exit 0; } } set timeout 5 expect { timeout { exit 0} "sword:" { send "apile123 " } } #---- work start here set timeout 5 expect { timeout { send_user "密碼錯誤 " exit 0 } ">" { send "cd c:abccde " } } set timeout 5 expect { timeout { send_user "Something Error " exit 0 } ">" { send "get "abc.txt " } } set timeout 600 expect { timeout { send_user "Something Error " exit 0 } ">" { send "bye " } } (Unlinux.com) 转载自:http://www.unlinux.com/doc/shell/20051026/82.html 【评论】 【加入收藏夹】 【大 中 小】 【打印】 【关闭】 ※ 相关链接
|