Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
expect on a socket

Posted by sirius_black (sirius_black), 6 November 2003
Hello everybody !!
I'm french so I'm not sure you will understand all the things I want to say  
I'm looking for a method tu use expect with socket
something like (If it would exists) :

set s [ socket localhost 9876 ]
expect -channel $s "ping!"
puts $s "pong!"

So I don't want to use expect with a classic "spawn telnet" because I want to create a program which can run on every platform running Tcl/Expect and only Tcl/Expect (no need of telnet).

So my question is :
how can I redirect the stream of the socket to Expect ?

If you want to contact me : sirius_black[at]imel.org

Posted by admin (Graham Ellis), 7 November 2003
I think I understand the question - and if I don't, it's just because I'm not yet fully awake this morning  

Spawn usually works with processes, as you say, but it can also work with files and devices using the -open option.   To quote Don Libes, the author of Expect, "The spawn command does not provide any facility for redirection or pipelines becuase the need for it is almost non-existent".   I wonder if he took the same view about sockets; he also says "to communicate with sockets, Expect can spawn telnet".

Have you considered using raw Tcl (rather than Expect) for your application?   The main niche that Expect is designed for is  automating those awkward programs which only provide user / command line interfaces, wheras programs that run to sockets are typically designed to talk to other programs and you probably don't need all the special facilities of Expect .... just a thought - the facilities for socket handling in Tcl are quite good, if underutilised!

Posted by sirius_black (sirius_black), 7 November 2003

Thank you for your answer.
Yes you have understood what I wanted to say.
I'll try 'raw Tcl' with socket (read and if) but it would be better to use Expect with socket (maybe in the next version of Expect ?)
Thanks !



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho