Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1239195
  • 博文数量: 264
  • 博客积分: 10772
  • 博客等级: 上将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 11:54
文章分类

全部博文(264)

文章存档

2012年(4)

2011年(51)

2010年(31)

2009年(57)

2008年(51)

2007年(70)

分类: LINUX

2009-01-10 00:04:30

#!/usr/bin/expect
# Assume $remote_server, $my_user_id, $my_password, and $my_command were read in earlier
# in the script.
# Open a telnet session to a remote server, and wait for a username prompt.
set remote_server 16.157.64.42
set port 30600
set login "auth s usera"
set lout lout

spawn telnet $remote_server $port
#expect "username:"
expect "^* OK IMAP"
# Send the username, and then wait for a password prompt.
send "$login\r"
expect "OK"
# Send the password, and then wait for a shell prompt.
send "$lout\r"
expect "OK"
# Send the prebuilt command, and then wait for another shell prompt.
#send "$my_command\r"
#expect "%"
# Capture the results of the command into a variable. This can be displayed, or written to disk.
#set results $expect_out(buffer)
# Exit the telnet session, and wait for a special end-of-file character.
#send "exit\r"
#expect eof

阅读(3457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~