首页 > 系统服务 > 详细

the usage of linux command "expect"

时间:2015-10-12 20:37:37      阅读:159      评论:0      收藏:0      [点我收藏+]

#! /usr/bin/expect -f
# this script is used to practise the command "expect"

#when "lindex" have been used here, the array index begins with 0 but not with 1
set user [lindex $argv 0]
set host [lindex $argv 1]
set passwd [lindex $argv 2]
set timeout 10

spawn ssh $user@$host
#expect "[yes/no]" {send "yes\r"}  // if ‘ssh-ing‘ the server for the first time, you may encounter this
expect "password:" {send "$passwd\r"}
interact

 

# modify the script mode to be 0744

# now, one may run "./login.exp your_name host_name your_passwd" in the bash shell, logging in the server successfully.

the usage of linux command "expect"

原文:http://www.cnblogs.com/bkylee/p/4872495.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!