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
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
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., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho