脚本一
#!/usr/bin/expect
set timeout 30
spawn ssh dashu@192.168.7.10
expect {
"(yes/no)?" {send "yes\n";exp_continue}
"password:" {send "ds\n";exp_continue}
"~]$ " {send {kubectl logs `kubectl get pod -n test | grep test-toolkit | awk '{print $1}'` -n test}
send "\n" ;interact}
}
脚本二
#!/usr/bin/expect
set timeout 30
spawn ssh root@[lindex $argv 0]
expect {
"(yes/no)?" {send "yes\n";exp_continue}
"password:" {send "xxx\n";exp_continue}
expect
"password:" {send "xxx\n";exp_continue}
expect "~]#" {send "cd /log && tail -f [lindex $argv 1].log\n";interact}
}
记录下:
脚本一里面可以使用awk方法,脚本二里面就不行
简书总计数字有bug吧。。编辑时候显示有131个字数,到发布就33个字数了。。额,这日更还能更得上去吗?好了,现在在勉强凑字数了。。还是要好好做好测试才对啊。。无语。。。本段文字之前的内容发布后只记了33个字数哈。。还有编辑时显示脚本代码有高亮,发布后没有代码高亮了。。。诶