ssh隧道到数据库。我正在尝试编写一个脚本,该脚本使用SSH隧道访问数据库。 我无法使其正常工作。 有人尝试过吗?
我已经设置了ssh密钥,并且可以运行打开的数据库,如果我在与脚本分开的cmd窗口中运行ssh命令,则可以返回它,但是如果我可以将所有内容集成到JSL中,我都希望它返回(因此,用户不必记住打开隧道)。
Names default to here(1);
rp = Run Program(
executable("ssh.exe"),
Options({"-tt", "-L 1414:localhost:1414", "test@test.com"}),
ReadFunction( "text" )
);
dt = open database(
"cxn_string",
"SELECT * FROM Test",
"Test"
);
rp << Write EOF();
提前致谢。
回复:SSH隧道到数据库。我猜想RunProgram永远等待着,试图从ssh.exe获取所有输出。
ReadFunction(“ text”),这意味着RunProgram应该阻塞直到程序完成,然后返回程序生成的任何文本(在您的示例中可能没有)。
这不会阻塞,并将所有输出复制到日志中:
ReadFunction(
Function( {this},
write(this << read);
)
)如果可行,则rp(在您的原始示例中)将是runprogram对象,而不是返回的文本。
https://community.jmp.com/t5/Uncharted/JSL-to-Control-Raspberry-Camera/ba-p/226243 使用plink.exe,它可能等同于ssh.exe。我不得不用
rp <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Write</SPAN><SPAN class="token punctuation">(</SPAN> <SPAN class="token string">"exit\!n"</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
彻底断开连接;我认为rp << writeeof应该可以,但是没有成功。
回复:SSH隧道到数据库。D'ah。 应该想到了。 谢谢。