+ -
当前位置:首页 → 问答吧 → expect 取目标主机的变量

expect 取目标主机的变量

时间:2011-07-19

来源:互联网

/usr/bin/expect <<EOF
set timeout -1
spawn /usr/bin/ssh [email protected]
  expect {

                "(yes/no)?" {send -- "yes\r"; exp_continue}

                "password:" {send -- "oracle\r"}

                }
expect "]"
send "echo $ORACLE_SID\r"
expect "]"
send "exit\r"
expect eof
EOF


怎么渠道10。10.10.100的ORACLE_SID值呢

谢谢指点

作者: 267020090   发布时间: 2011-07-19

send "echo \$ORACLE_SID\r"
然后可以用expect -re 构造表达式从 $expect_out(n,string)中取得想要的部分
也可以从expect_out(buffer)中用regexp或string等命令取得想要的部分

作者: waker   发布时间: 2011-07-19

热门下载

更多