ITPub博客

首页 > 应用开发 > IT综合 > expect使用一例(转)

expect使用一例(转)

原创 IT综合 作者:post0 时间:2007-08-11 12:10:01 0 删除 编辑
expect使用一例(转)[@more@]

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 " }

} (linux知识宝库

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8225414/viewspace-944889/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    2018
  • 访问量
    8226627