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:   spawn telnet from unix to windows

Posted by johndo (johndo), 20 March 2003

Does anyone have any experience
running an expect script to spawn telnet,
from unix ( Solaris 7 ), to windows (NT), to invoke
an executable ?

 I was able to run a batch file, but not an
executable.   Then I tried to call the executable
from the batch file, which didn't work either.

John Doppert

Posted by admin (Graham Ellis), 20 March 2003
There shouldn't be a problem running an executable rather than a batch file - telnet deals with sequences of bytes sent and received over TCP port 23 and whether those sequences cause batch files or executables to run isn't relevant.

Question.  Can you run your executable via telnet from the Solaris box outside expect?  If you can, then you should be able to do so through expect.  If you cannot (if the executable calls up windows, or if the executable is hardcoded to the keyboard of the Windows box rather than STDIN for example) then you have other issues to solve outside expect.

Issues to look at if you CAN run the executable directly via telnet:
a) Are you getting your new line sequences right sometimes you need to use the \r (return) character and  at other times the \n (newline; linefeed) in your send and expects.
b) Do you have timing matters to consider?  An expect script is very much faster to react than a human operator; you should be careful to wait for the very last byte to be received before you do a send and you may even then want to wait a few milliseconds in some situations.

Other useful tools are log_user (leave it in default condition initially or switch back to default so that you can see where your expect / send sequence jams) and send_human and send -h to make your automated inputs mimic human habits even more closely.

This page is a thread posted to the opentalk forum at 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., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho