| |||||||||||
Calling a telnet application at the button click Posted by skumar003 (skumar003), 28 January 2003 I have an application that connects to a host. That needs to be executed at the command line.execute port@host this.package. How do I call this in a GUI button so that I click the button I get that executed. Cheers, Posted by admin (Graham Ellis), 28 January 2003 Then you'll be wanting the Tk extension and the expect extension - you'll find them together in "expectk".Wrap the spawn send and expect sequence (and everything else you want to do to run the the remote command) into a proc, and create a widget (probably a button) that calls it up with its -command option. Use a pack geometry manager to display the button, and when your code reaches the end it will wait for button hits. You'll probably also want to create and pack a label onto which to display your results, and you might want to have a look at updateidlestasks if your remote application can take a while to run - otherwise your user may be left thinking that the application has hung. It's fabulous fun writing this sort of thing, code typically turns out quite short, but you really need a good head on your shoulders and to understand things like deferred blocks .... Posted by skumar003 (skumar003), 28 January 2003 Have U seen a free source example of this kind anywhere on the net?Posted by admin (Graham Ellis), 28 January 2003 Well - it's really just a question of combining Tk techniques and Expect techniques ... can't say that I've seen an example posted for free on the net that fulfills the criteria; the nearest I can offer is an application that spawns a ping and reports back - on our web site at http://www.wellho.net/resources/tcl.html and (you're in luck!) it's the course example "tkpingle" that's mentioned on the "view sample program" box. Posted by skumar003 (skumar003), 28 January 2003 Can I invoke a batch file by the click of a button?-----Example-of-what-it-is----------- #!/usr/local/bash connect port@host scriptfile -------------------------------- ---What I want to achieve-------------- button .redo -text "Connect to NE" -command { #!/usr/local/bash connect port@host scriptfile } -------------------------------- Posted by admin (Graham Ellis), 29 January 2003 If the batch (script) file is located (and to run) on the computer that's running the Tcl/Tk script then, yes ... have a look at the exec command, and also the catch command so that any errors it generates won't cause the whole Tcl program to fail.If the batch command script requires interaction, or to be run on a remote machine (as your initial question kinda implies) then expectk is the thing to use. There's thorough coverage in Don Libe's book "Exploring Expect" - full book details at http://www.wellho.net/book/1-56592-090-2.html This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |