lucas
lucas

Reputation: 53

stdout from putty in text widget

I'm using putty to connect with server and execute a command, but I have no idea how to redirect the command output to text widget.

exec patchtoputty/putty.exe -ssh myserver -pw mypass -m mycommand

Normally this should (?) works:

catch {exec patchtoputty/putty.exe -ssh myserver -pw mypass -m mycommand} results
.text insert 1.0 $results

but not in this case where I'm executing putty (or for example cygwin) command which has his own terminal window.

Regards, lucas

Upvotes: 0

Views: 861

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137727

It's very tricky to grab the output of a window and insert it into a text widget; you'd have to regularly grab the screen and OCR the results or something. Ridiculous.

But with putty, your best bet is to instead switch to plink.exe (= “Putty LINK” I think) from the same family. It's basically putty but without the windowing stuff and with the ability to run nicely in a pipeline. It takes the same options as putty, so modifying your code should be really easy.

catch {exec wherever/plink.exe -ssh myserver -pw mypass -m mycommand} results
.text insert 1.0 $results

(Building your own putty? Just make sure you build plink at the same time.)

Upvotes: 2

Related Questions