Installing expect on windows

Working with Expect script on windows environment

Thursday, February 18, 2010

Expect and windows xp

[if you know about Expect, you can jump your interested area]

Introduction
In wikipedia, about expect «Expect is a Unix automation and testing tool, written by Don Libes as an extension to the Tcl scripting language, for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. It uses Unix pseudo terminals to wrap up subprocesses transparently, allowing the automation of arbitrary applications that are accessed over a terminal. With Tk, interactive applications can be wrapped in X11 GUIs.»

In simple words, Expect is very powerful scripting language to test complex protocol. Mostly used for conformance testing in networked environment. Expect can send the data across network and validate results with predefined values. For more details use official expect website @ expect.nist.gov. Working with expect is fun in windows environment.

Need of Expect in Windows
Now, let’s talk about the need of Expect in windows. Most of us have windows environment at work location (due to any reason). And, it is not worth to set up linux environment for Expect only. Moreover, with small steps, it is possible to set up expect on windows environment too.

Steps to start expect on Windows
So, follow following simple steps and your expect script will work as charm 🙂

  1. Download Active Tcl from http://www.activestate.com/activetcl/downloads/
  2. Install (Typically @ c:/Tcl/ directory)
  3. Go to Bin directory in Command prompt (Start > Run > commad > cd c:\Tcl\bin)
  4. (only required if you use proxy) teacup proxy

(e.g. teacup proxy myproxy.com 8080)

  • Instruct teacup to install Expect by teacup install Expect
  • DONE!
  • Convert Expect file in windows format
    Now we have expect installed and we need to convert expect file into windows format. which is infect more simple. It is optional but good idea to convert extension to .tcl.

    We need to add following lines @ beginning of expect file.
    Running expect file in windows
    Go to command prompt and navigate to folder where you kept your expect script.
    Run using tclsh85.exe file as follows.

    how to install Expect for windows using ActiveTCL 8.6 x86

    I’m trying to install Expect for Windows using ActiveTCL and I’m having a helluva time. I understand I need to use teacup/teapot? Is there any documentation at all? I’m trying to run teacup and it says «can’t create directory» on my network drive, it’s trying to install in a random directory that I can’t seem to change..

    I’ve spent a day trying to figure out how to install, what I thought would be, a simple program.

    3 Answers 3

    I am convinced that Expect does not work on 8.6, at least as advertised by the documentation on ActiveTcl’s site. I have spent the last three hours trying to get it to work without success. I uninstalled Tcl 8.6, and downgraded to 8.5 (32 bit). Once that was done, I opened the «Tclsh» application and ran the command «teapot install Expect» That is probably not the solution you are looking for, but that’s what I did.

    Читайте также:  P7h55 m lx драйвера windows 10 64 bit

    Run command «teacup install Except» in prompt. You can type «teacup help» to find more information.

    Yes! Thanks for this post @Sean Farley! Adding Expect to ActiveTcl was a clear as mud. I agree that it does not seem to be supported in Tcl 8.6 or 64-bit Tcl 8.5. After installing & uninstalling both of those the 32-bit version worked (also I think it’s «teacup install Expect» to install).

    Not the answer you’re looking for? Browse other questions tagged tcl expect or ask your own question.

    Hot Network Questions

    Subscribe to RSS

    To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

    site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

    By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

    Can I use Expect on Windows without installing Cygwin?

    Expect is a module used for spawning child applications and controlling them. I’m interested in Python and Ruby.

    6 Answers 6

    Notes in the wexpect.py file (typos unchanged and highlighting added)

    Wexpect is a port of pexpext to Windows. Since python for Windows lacks the requisite modules (pty, tty, select, termios, fctnl, and resource) to run pexpect, it was necessary to create a back-end that implemented any functions that were used that relied on these modules. Wtty.py is this back-end. In the Windows world consoles are not homogeneous. They can use low level or high level input and output functions, and to correctly deal with both cases two child processes are created for instacne of Spawn, with an intermidate child that can continuously read from the console, and send that data over a pipe to an instance of wtty. Spawner.py is resposible from reading and piping data.

    I’ve left as much code intact as I could and also tried to leave as many comments intact is possible (espicially for functions that have not been changed) so many of the comments will be misleading in their relationship to os specific functionality. Also, the functions sendcontrol and sendeof are unimplemnted at this time, as I could not find meaningful Windows versions of these functions.
    additionally, consoles do not have associated fild descriptors on Windows, so the global variable child_fd will always be None.

    Installing expect on windows

    There are multiple efforts and products offering expect for MS Windows.

    Gordon Chaffee ported Expect 5.21r1b1 . Binary and source are available at [L1 ][L2 ], and also present in MyrmecoX (?). This corresponds to Tcl version 8.0.

    A port of Expect (based off 5.43) was available from ActiveState [L3 ], included in ActiveTcl 8.4.11.1 or later. Due to discontinuation of Teapot support on ActiveTcl, Expect is now de facto unavailable for ActiveTcl. Available Tcl packages on ActiveState website are yet to be updated accordingly, and may be misleading.

    Читайте также:  Центр решений hp для windows 10 не работает

    It could get interact if someone really needs it. All that’s needed is lots of development time and good verification test cases. — DG

    cygwin’s Expect works fine under Cygwin as long as what you’re expect’ing upon is a cygwin application. It does not work with normal/native Win32 console applications. — Andreas Kupries [2001-sep-20]

    During the early winter 2001-2002, Telindustrie LLC briefly supported David Gravereaux’s work to port 8.4 to Windows. Davy’s pretty much the world’s most knowledgeable person about what this will involve. He writes,

    The windows specific code is already in the official repository off on a branch [L4 ]

    There are lots of ways this could go. Perl (and Python?) people might help out with Expect, and Win* expertise perhaps would be part of the package. Also interesting is a comp.lang.tcl exchange [L5 ] between Jiang Wu and Jeffrey Hobbs; note mention of how more of Expect might move into the Tcl core.

    [Why and how it doesn’t work for Win95. Problems with interact.] [Experience with Win2000.] [ Pure-Tcl telnet available—this sometimes suffices.]

    [Expect 5.25/Tcl 7.6 for Japanese.] [5.31/8.2 as source.]

    [ Tony Summerfelt’s been mostly successful with Expect under Win2000.]

    Is there a need for a trap to receive the «signal» when Expect is used as a Windows service? [L6 ]

    IMO, No. The windows model provides this and the «shell» being used for the service control should get «going down» notices and hopefully «do the right thing». If expect.exe knows nothing for being a windows service, for which it shouldn’t being a CLI shell, one should build a shell with all the needed service parts to get the notifications they need. See tclsvc — Tcl as an NT Service — DG

    LV Sometimes people talk about wanting Expect running under Windows, but it turns out that they really are wanting to drive GUI applications, which is a use for which Expect is not intended.

    escargo 19 Apr 2005 — Using driving as a search produced (among others): Techniques for ‘driving’ Windows applications.

    AM Expect for Windows as available in ActiveTcl 8.4.xx works very very nicely, but there is a caveat:

    I have no idea why, but I really had trouble getting a simple expect script to run (exp_send did not work if you gave it an explicitly spawn ID, the whole program hung when the input from the spawned process was not a complete line — the very reason I needed Expect in the first place).

    These problems are probably due to the way DOS-boxes work. It all works fine when you use wish.

    LV What is a DOS-box?

    DG: I think what AM is saying refers to executing commands from the system prompt. IOW:

    cmd.exe is not needed! Just spawn ftp.exe. I think there’s a bug with how E4W tries to get text through cmd.exe but can’t for some reason (unknown).

    Читайте также:  Cat how to linux

    SG: cmd.exe is not needed if you’re spawning an .exe file — it is necessary if you’re trying to spawn a .bat file. AIUI, there’s no way to use ActiveState’s expect with a bat file. The version of expect with cygwin seems to work with cmd.exe, however.

    Njay: I had worked with expect for Windows before, but I recently was unable to get it working on a quad-core with XP. spawn simply doesn’t launch the process and doesn’t issue any error. Also tried the «open |» feature but there were some unexplainable quirks so, I started to think that a simple version of expect could be implemented in Tcl. So here it is; the limitations are plenty but for basic applications it should do the trick.

    Njay: I did a minor update on the expect proc above and added the pause proc. This code is a lib.

    AMG: What does [send_user] do? Can’t it just be «puts $args»?

    send_user takes care that the arguments are evaluated in the caller’s context. It is written as if the default context could have variables that would hide the caller’s variables. Of course the client could have had that outcome by just using puts. send_user is «expected» to be in expect though.

    RJ: There’s currently no version of Expect that works correctly with 64bit Windows 7 and above. Does anyone have time to get this working?

    As I have investigated, «Expect» does NOT appear to be included in ActiveTCL v8.5 for windows (Installer name: ActiveTCL8.5.13.0.296436-win32-ix86-threded.exe). Could anyone please confirm that and/or update the relevant text.

    Hi, the link to Gordon Chaffee’s Expect port in invalid(maybe outdated). Do you know what could be the right link now?

    Fix problems that block programs from being installed or removed

    Note: Use these steps for Windows programs. If you’re having problems with an app you got from Microsoft Store, go to Fix problems with apps from Microsoft Store.

    The Program Install and Uninstall troubleshooter helps you automatically repair issues when you’re blocked from installing or removing programs. It also fixes corrupted registry keys.

    First, you’ll need to download the troubleshooter.

    If you see the File Download box when you start downloading, select Run or Open.

    The troubleshooter provides steps for you to follow. If a program isn’t listed in the uninstall options, you’ll be asked for that program’s product code. To access the code, you’ll need a tool for reading MSI files—which is typically available to IT professionals. You’ll find the product code in the property table of the MSI file.

    What it fixes

    The troubleshooter helps fix problems that:

    Corrupt registry keys on 64-bit operating systems.

    Corrupt registry keys that control the update data.

    Prevent new programs from being installed.

    Prevent existing programs from being completely uninstalled or updated.

    Block you from uninstalling a program through Add or Remove Programs (or Programs and Features) in Control Panel.

    If you’re trying to remove malware, you can use Windows Security (or another antivirus tool), or you can use the Windows Malicious Software Removal tool.

    Оцените статью