您的位置:首页 > 文档 > 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

评论】 【加入收藏夹】 【 】 【打印】 【关闭
 *  请尊重我们的劳动,转载请注明出自UnLinux.Com及作者名 * 

※ 相关链接
 ·expect使用一例  (2005-10-26 00:49:42)

Copyright © 2005 UnLinux.Com All Rights Reserved