Unable to spawn telnet session from TCL script with Expect on Windows XP Professional

Posted by Bharat Shah on 2008-01-08 16:18

I was using ActiveTcl Ver 8.4.14 with my older PC with Windows XP Ver 5.1.
I just got new PC with Windows XP professional Ver 5.1 as well.
I am using "package require Expect" at the begining of my script.
I loaded ActiveTcl Ver 8.4.14 and script died at the following command.

set pid [spawn telnet 23]

I loaded ActiveTcl Ver 8.4.17 and same issue.
ActiveTcl Ver does not contain Expect package and useless for me.

I nedd help. Does anyone know what's going on?


Vamsi Krishna | Wed, 2008-01-09 22:13

I wrote some functions in C. To create Tcl my own commands. Now I want to combine these Tcl commands with my gui{which has been created in TK}. Can you please suggest me how to combine?

Thanks and Regards
Vamsi Krishna. M

mstinaff | Fri, 2008-02-22 12:24

I have the same issue as well. I tried 8.5 and then ran teacup -install Expect. same fail. The exact error I get is:
The exception unknown software exception (0xc0000409) occurred in the application at location 0x59a7295d.

this is the same error and location if I use 8.5 or 8.4. Both versions of Expect are 5.43 though.

catalinmy | Fri, 2008-02-22 13:46

And to me, TCL crash after: shawn ping . I have Windows XP SP2 and Active TCL 8.4.11 (Expect are 5.43).

weyersjj | Sat, 2008-04-12 01:39

See link:
Choose the OptOut mode:
DEP is some kind of protection. You can exclude applications from this protection by adding this applications (telnet, ftp etc.) to that list.
Yust start your configuration tool in XP choose the classic gui->system-> advanced->Dutch: Prestatie/English:?->(Dutch: Instellingen: English: Configuration/Preferences?)->*Dep* and add your programs to the list.
Reboot the computer.

sschen | Mon, 2008-04-14 12:44

This is the solution:
Modify the c:\boot.ini file as

It will allow to spawn the process.

nelsonrherron | Thu, 2009-11-19 13:12

Unable to spawn telnet session from TCL script w/ Expect on Vista. Same problem on Vista. Code:

puts "Hello, World\n";
set x 3;
puts $x;
package require Expect;
puts "Hello, World\n";
set x 4;
puts $x;
spawn telnet


C:\Utilities\tcl>tclsh85 test.txt
Hello, World

Hello, World

The system cannot find the file specified.
while executing
"spawn telnet"
(file "test.txt" line 8)


kutik | Tue, 2010-01-05 03:43

Telnet is disabled by default installation in Vista.
Enable it via Control Panel or use
'pkgmgr /iu:\"TelnetClient\'

ttapping | Thu, 2010-01-14 09:23

I see the same issue as reported above. Telnet is installed and I can launch via CMD.

Open a Wish85 Console and type:
% package require Expect
Response: 5.43
% spawn telnet
Response:The system cannot find the file specified

I saw posts that DEP might prevent this from working, although 'spawn ftp' works fine. I ran "bcdedit.exe /set nx AlwaysOff" from the command line and it completed successfully. I rebooted but still can't 'spawn telnet'.

Anyone have an idea how to fix this?

Thanks in advance.


ttapping | Fri, 2010-01-15 08:02

Got another box, installed Win XP SP3 32 bit and installed tcl.

Ran 'spawn telnet' and it worked like salmon returning to their home stream! :D

peter2008 | Sun, 2011-02-06 06:09

I did it.
It seems that spawn cannot work with telnet shipping with 64bit version windows 7, but it can work with the telnet shipping in windows xp. So replace the win 7 telnet with xp telnet would be ok.

I have tried it and it works. Bingo!

juls858 | Fri, 2011-06-10 10:38

I've tried this and could not get it to work on Windows 7 x64.
I've copied a 32bit telnet.exe from a windows XP box and get "spawn cannot find the file specified" error.

I've even tried exluding telnet.exe from DEP.

Could you tell us exactly how you got this to work?


gunns | Sun, 2011-06-19 16:32

Use "plink.exe" instead of telnet.

Ex. spawn plink -telnet

Available from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

hareesh | Mon, 2014-04-28 05:48

I am getting in to tclsh crash when spawn telnet session on win8.1, Win8.I had experience the same issue in Win7 as well, but this issue was not seen after Disabling Data Execution Prevention using command “ bcdedit /set nx AlwaysOff ”.
TCL 8.4
% package require Expect
% spawn telnet
-->> crash seen
Faulting application name: tclsh.exe, version:, time stamp: 0x4f32d408
Faulting module name: dbghelp.dll, version: 6.3.9600.16384, time stamp: 0x52157b79
Exception code: 0xc0000005
Fault offset: 0x000c718a
Faulting process id: 0xe60
Faulting application start time: 0x01cf62ed2bb416ab
Faulting application path: C:\TCL\bin\tclsh.exe
Faulting module path: C:\Windows\system32\dbghelp.dll
Report Id: 760c1370-cee0-11e3-971b-0050b6574c32
Faulting package full name:
Faulting package-relative application ID:

Anyone have an idea how to fix this?

Thanks in advance.


vikas.devgun | Thu, 2016-06-16 08:18

Guys any one having solution for the issue where spawn not giving any response on windows 7 64 bit OS

. i am currently using TCL version 8.6.0 , expect version 5.43.2 .

below given command line not giving any output :
spawn plink32 -ssh abc@