Help with spawning a process in an Expect script

Posted on 2013-09-09
Medium Priority
Last Modified: 2013-09-11
I am trying to spawn a process in an expect script and I keep getting an error message that it can't find the file I am trying to spawn.  I am trying to login to an ssh client (putty) that lives on my local computer

Here is the the first line of the expect script:

#first start the process
package require Expect
spawn ssh library.tufts.edu

And here is the error message I am getting:  

   C:\Tcl\bin>tclsh library.tufts.edu.tcl
The system cannot find the file specified.
    while executing
"spawn ssh library.tufts.edu"
    (file "library.tufts.edu.tcl" line 6)

It seems there is some syntax I am missing to spawn the process
Question by:Finlay11
  • 2
  • 2
  • 2
LVL 40

Expert Comment

ID: 39478706
try to put the full path to ssh or set your PATH env variable to include the dir ssh is in
LVL 35

Accepted Solution

Duncan Roe earned 2000 total points
ID: 39481550
You have to use the expect command. tclsh is not going to do it.

I see you're doing it under Windows. There is no free expect for Windows as such.
But, you can install Cygwin and that has expect.

Author Comment

ID: 39481910
Thank you.  I will try installing cygwin.
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.


Author Comment

ID: 39483560
I installed cygwin and included tcl as part of the installation.  But I can't seem to find expect within the cygwin directory and it does not recognize the command "expect" from the command prompt.  What am I missing?  

Thanks in advance
LVL 40

Expert Comment

ID: 39484336
try to run find . -name "expect*"
LVL 35

Expert Comment

by:Duncan Roe
ID: 39485135
You probably didn't install expect. Run the installer again, and when you get to the screen with all the categories in it, enter expect in the search box at top left hand of screen.

Remember you have to use a bash command prompt, not CMD.EXE

You might also want to install Cygwin's copy of ssh

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question