| |||||||||||
Problem with expect/spawn on Linux Posted by meredith.courtney (meredith.courtney), 13 February 2004 Hi:I made an Expect script that ran on a Windows box, and it works. (It controls a serial port in order to simulate the Central Office side of an SMDI link.) The Windows box won't run enough copies (plenty of memory and CPU available, but it runs out of some non-obvious resource), so I decided to try rebuilding the PC as a Linux box. My Expect script (suitably modified for the local environment) doesn't work, and neither does the "ftp-rfc" sample program. Both will spawn the target program (kermit or ftp), and then take a segmentation fault when the script issues the "expect" command to look for a prompt issued by the target program. (I can invoke both kermit and ftp from the command line, and they run.) When I add a line to the script (either one) to show me the value of $spawn_id, it prints "exp4" or "exp5". I was expecting to see a pid. My experience with Linux (RedHat 9) can be measured in hours, and in single digits at that, and I'm a beginner at Expect as well - but I think the example really ought to work. Have I missed some sort of setup trick? tcl version: tcl-8.3.5-88 expect version: expect-5.37-1 kernel: kernel-2.4.20-8 (RedHat 9) I'd be very grateful for any advice on how to proceed here. thanks Meredith Posted by admin (Graham Ellis), 14 February 2004 Expect scripts are notoriously unportable. You're writing a program that sits on top of the "human interface" to the file transfer protocol (in this case) and although this FTP client may appear to work in a similar way from one OS to the other, almost certainly there will be differences. It's probable that you'll need to go back and check you sends and expects out from first principles and make alterations ... the "human interface" on clients even tends to change between one release of an OS and the next - silly changes like the capitalisation of a word that you key to in expect! Another pointer - be aware of the differing line end characters between Linux and Windows - Linus uses \n and Windows uses \r\n - this applies particularly in files, but may catch you too. The spawnids look fine by the way, and the sofwate releases all look good / modern. Bit concerned at the "segmentation" problem, but I suspect you'll isolate that / it'll go away as you check out your send and expect sequences. Expect is a very powerful tool but it *is* in effect parallel / multithreaded processing - your process and others - and that means that development / debugging testing is always great fun and you need to be on your toes! Posted by meredith.courtney (meredith.courtney), 20 February 2004 Hi: The reassurance about the spawn_ids was very helpful, thanks.The problem with the seg fault was apparently the Expect version. I removed the 5.37 version and installed expect-5.38.0-88, and the seg fault went away. My simulator is working now. thanks Meredith Posted by admin (Graham Ellis), 20 February 2004 Glad it's workingThanks for coming back to complete the thread - much appreciated! Graham Posted by polsoni (polsoni), 1 April 2004 on 02/13/04 at 19:59:35, meredith.courtney wrote:
Posted by admin (Graham Ellis), 1 April 2004 Thanks for quoting that, Soni (and welcome to the board). Do you have a question that relates to it, or some follow-up information? If so, they didn't make it to your post Posted by polsoni (soni), 1 April 2004 Sorry about that graham I had a similar issue, so wanted to post by modifying, but went on to post it as a new issue.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.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |