我正在尝试编写一段脚本,通过TCL/Expect从一个系统爬升到另一个系统。这对我来说是有效的。我需要一个正则表达式,其中将 expect "$ " 和 expect "# " 结合在一起,以便可以包括路径中任何带有提示符的系统。
#!/usr/bin/expect
# Using ssh from expect
log_user 0
spawn ssh test@192.168.2.24
expect "sword: "
send "test\r"
expect "$ "
send "ssh beta\r"
expect "# "
send "uptime\r"
expect "# "
set igot $expect_out(buffer)
puts $igot