我正在尝试编写一个脚本,它通过TCL / 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
用这个:
expect -re {[$#] }