Linux expect
来源:互联网 发布:hp网络打印机怎么设置 编辑:程序博客网 时间:2024/06/11 12:42
一个expect使用的例子程序
[root@dba-server01 tftpboot]# less expect-ssh.exp
//提示用法proc usage {} { puts stderr "usage: $::argv0 username password hostip" exit 1}proc connect {pass} { expect { "(yes/no)?" { send "yes\n" expect "*password:" { send "$pass\n" expect { "*#" { return 0 } } } } "*password:" { send "$pass\n" expect { "*#" { return 0 } } } } return 1}if {$argc != 3} { usage }set username [lindex $argv 0]set password [lindex $argv 1]set hostip [lindex $argv 2]spawn ssh ${username}@${hostip}//这里表示如果连接不成功则返回!if {![connect $password]} { exit 1}send "touch /home/oracle/test.txt\n"//注意转移回车的使用,以免和exit指令连在一起.这里是目标机要执行的指令.send "exit\n"expect eof参见http://www.cnblogs.com/super119/archive/2010/12/18/1909977.html
- expect linux
- linux expect
- Linux expect
- Linux expect
- linux expect
- linux expect
- linux expect
- Linux expect
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 应用
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- linux expect spawn、linux expect 用法
- expect spawn、linux expect 用法小记
- expect spawn、linux expect 用法小记
- expect spawn、linux expect 用法小记
- Oracle Process Summary
- Oracle timestamp & SCN
- Oracle dba_data_files dba_segments dba_free_space
- Oracle Flashback
- Oracle external table & SQL*Loader
- Linux expect
- kickstart research
- 15日,7月,2012 - Drupal,吃饭,超级玛丽
- 随笔之0715
- 苹果打击刷排名措施有利于净化App Store竞争环境
- 高山流水
- XSLT(11) Named templates, matching templates or for-each
- 图标的尺寸
- 网页制作(四)---重新声明 JavaScript 变量