Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Expect window

Posted by MikeLG (MikeLG), 4 May 2006
Hi there,

I've been working on some scripts which run OK, but always show the small 'console' window. Using the exit command at the end of the script, we can close it, but we really don't want it to appear at all.

Do you know of any way to prevent this? (I apologise if this has been answered elsewhere, but I couldn't find any instance of it)

Many thanks in advance.



Posted by admin (Graham Ellis), 4 May 2006
Nope, I don't this has been answered elsewhere - at least on this site.

I regularly use Expect on a Linux or OS X box ... and don't have any extra windows pop up if the expect program is run from a file. I'm guessing you're running on Activestate Tcl with Expect under Windows?    

If you can confirm or correct my guess that would be great - I'm probably not the best one to answer the Windows question but at least it will define the problem better for anyone who's used that particular implementation in anger.

Posted by MikeLG (MikeLG), 5 May 2006
Hi Graham,

Thanks for responding. You're correct, it is Activestate TCL with Expect for Windows.

We've tried looking at the demos supplied with it, as they don't seem to display the window while the script is running, but can't see an obvious reason.

Any assistance with this issue would be very much appreciated, especially as this is a time-sensitive project we're working on.



Posted by admin (Graham Ellis), 5 May 2006
A thought ... if you're able to post up a short script that exhibits the problem - cut it down to 20 lines or so - I'll run in on a Windows / ActiveState Tcl system and see if I can spot anything.  

I've tried this particular release only a little and can't say I've had the same problem, so it's probably best to work from sample code rather than trying to guess.

Posted by MikeLG (MikeLG), 5 May 2006
That's extremely kind of you, many thanks. Here is one of the scripts. As you can see, it uses Telnet to connect to a wireless access point, then issues the commands necessary to force a save prompt before reloading it. Please let me know if you need any further info.

package require Expect

     exp_log_user 1

# set ::exp::winnt_debug 1

     set timeout 10

# 1. Open a telnet session to the AccessPoint.
     spawn telnet 10.0.2.4

# 2. Wait for a login prompt.
     expect -re ".*name:" {
       
# 3. Send user login name.
       exp_send "Cisco\r"
     }

     expect "Password:" {
       
# 4. Send the password.
         exp_send "Cisco\r"
     }

     expect -re ".*>" {
       
# 5. Send the 'en' command.
         exp_send "en\r"
     }

     expect "Password:" {
       
# 6. Send the password.
         exp_send "Cisco\r"
     }
     expect -re ".*#" {

# Steps 7-9 send dummy command to force "save prompt"

# 7. Send 'conf t' command  
         exp_send "conf t\r"
     }

     expect -re ".*onfig*" {

# 8. Send 'access-list 99 deny any' command  
         exp_send "access-list 99 deny any\r"
     }

     expect -re ".*onfig*" {

# 9. Send 'exit' command  
         exp_send "exit\r"
     }

     expect -re ".*#*" {


# 10. Send the 'rel' command.
         exp_send "rel\r"
     }

     expect -re ".*Save*" {


# 11. Where prompted to save, Send the 'no' command.
         exp_send "n\r"
     }

     expect -re ".*eload*" {


# 12. Where prompted to reload, send the 'yes' command.
         exp_send "y\r"
     }

exit


     



Posted by admin (Graham Ellis), 7 May 2006
Mike,

I've had a play with your code ... and I'm not seeing anything I wouldn't anticipate.   However, I might have a clue.

Are you by any chance running the supplied examples through the tclsh program, but your own example through wish? Tclsh is the Tcl program without the Tk GUI, and runs typically from the command line.   Wish is Tcl with the Tk GUI and pops up an extra window.

I ran your example through Tclsh and it worked fine, timing out when it failed to connect to the Cisco router I don't have.  Through wish it indeed popped up the extra Tk window and trapped the timout message into a wish error dialog.

If your unexpected window is square, and about 150 x 150 pixels, the almost undoubtedly this is the cause.   To test if it's the case, run from the command line with tchsh, and again with wish.  In the first case there should be no extra window and in the second there will.

Once you know that this is what's causing the problem, you can fix it by changing extensions and / or associations of extensions - you probably know better about these than I do as I'm not really a Windows person  

-- Graham



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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho