| |||||||||||
How to ssh and execute a particular command Posted by chets (chets), 9 October 2007 HI,im new to this TCL/TK programming, wanted to know how to spawn another m/c and execute command over there. i want it from TK (window) instead of command line. Can anyone help me in this, any example in Expectk would be helpful. Thanks, chets Posted by admin (Graham Ellis), 9 October 2007 Here's an example with Expect (no Tk) which should help you with that end ...Code:
I tested that .. and it worked for me: Code:
Posted by chets (chets), 10 October 2007 Thanks a lot for the response... i got it and implemented in my setup it worked fine in CLI.eg: set Machine $src set Password "nextone" spawn ssh $Machine expect "Password:" send "$Password\n" expect "inex:~ # " send "cd /root/tools/sipp/\n" expect "inex:~/tools/sipp # " send "./sipp -sn uas\n" interact but rather than cli i wanted to spawn a window in GUI, i heard about expectk would help in this. any example/ regarding expectk would be heplful... Thanks, Chets Posted by admin (Graham Ellis), 10 October 2007 We have loads of Tk examples starting here. Individual bits of source code on each topic in the middle column, new topics across to the right.Posted by chets (chets), 11 October 2007 well Thanks again.i followed one of the example and written a script for ssh it worked. #!/usr/bin/expectk proc getfiles {host} { log_user 0 set id [spawn ssh $host] expect "Password: " exp_send "abcd\n" expect "d123:~ # " interact } set hostname "computer name" entry .host -textvariable hostname button .do -text go -command { getfiles $hostname } pack .host .do but here once the script is run through terminal and after entering comp IP and hit go button it spawns ssh in the same terminal i want to pop up new window where it should spawn ssh i used toplevel but din't worked. any idea on this would be help ful 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 |