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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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