ssh tunnel to database.I'm trying to write a script that uses an SSH tunnel to a database in order to access it. I'm not able to get it to work. Anyone else tried this before?
I've already setup my ssh key and I can run the open database and have it return if I run the ssh command in a cmd window separate from the script but I'd like it if I can integrate everything into the JSL (so users don't have to remember to open the tunnel).
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();
Thanks in advance.
Re: ssh tunnel to database.I'm guessing RunProgram waits forever, trying to get all the output from ssh.exe.
ReadFunction("text") which means RunProgram should block until the program finishes, then return any text the program produced (probably none in your example.)
This won't block and will copy any output to the log:
ReadFunction(
Function( {this},
write(this << read);
)
)If that works, rp (in your original example) will be the runprogram object rather than the returned text.
https://community.jmp.com/t5/Uncharted/JSL-to-Control-Raspberry-Camera/ba-p/226243 uses plink.exe, which is probably equivalent to ssh.exe. I had to use
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>
to get a clean disconnect; I thought rp<
Re: ssh tunnel to database.D'ah. Should have thought of that. Thanks.