Ssh 使用tcl/expect准备隧道
作为更大计划的一部分(跳过一系列跳,然后在禁用PortForwarding的设置中创建到mongodb的端口隧道),我尝试创建一个tcl/expect脚本,以验证是否可以中继tcl/expect准备的流 这是我的实验:Ssh 使用tcl/expect准备隧道,ssh,expect,portforwarding,netcat,Ssh,Expect,Portforwarding,Netcat,作为更大计划的一部分(跳过一系列跳,然后在禁用PortForwarding的设置中创建到mongodb的端口隧道),我尝试创建一个tcl/expect脚本,以验证是否可以中继tcl/expect准备的流 这是我的实验: # terminal 1 [listen to 2000] nc -l 2000 # terminal 2 [listen to 200 then connect it to 2000 using expect] socat tcp-l:200 system:'./nc-tes
# terminal 1 [listen to 2000]
nc -l 2000
# terminal 2 [listen to 200 then connect it to 2000 using expect]
socat tcp-l:200 system:'./nc-test.exp'
# terminal 3 [connect to 200]
nc localhost 200
还有我的tcl/expect简单脚本(nc test.exp
):
现在的问题是,我在terminal 3
中写的所有东西都回想起我自己。奇怪的是,当我直接将socat
连接到nclocalhost 2000
或直接执行tcl/expect脚本时,这种情况并没有发生。你能帮我想想吗
- 是什么引起了不必要的回声
- 我的大计划可行吗?(我最担心的是保持溪流畅通)
expect
脚本中的stty
命令作用于/dev/tty
,这可能是终端2中的tty。但是,spawn
创建另一个pty来与它启动的命令对话。该tty将从当前tty(即端子2)继承,因此将启用echo。只需将stty raw-echo
行移动到spawn之前就足够了,或者更明确地说,您可以通过如下命令设置stty设置,以供spawn
使用
set stty_init "raw -echo"
在生成之前
set stty_init "raw -echo"