From: Roland G. <RGi...@cp...> - 2003-08-27 07:23:23
|
sorry for the belated reply... expect wrote: > On Mon, 04 Aug 2003 17:19:18 -0400 > Sayre Swarztrauber <sa...@qu...> wrote: > > >>I am new to Expect. I am using it to control some serial devices that >>our company manufactures. They are connected on /dev/tty ports directly >>as RS232 devices. I open the port using IO::File and then connect that >>handle to Expect. >> >>I have a problem where Expect.pm occasionally closes the filehandle on >>the port giving the following message from the debug output: >> >>Waiting for new data (6 seconds)... >>handle id(3): new data. >>handle id(3): EOF >>handle id(3): closing... >>Returning from expect with TIMEOUT or EOF >> >> >>I have patched my problem by commenting out the >> >> $exp->hard_close(); >> >>on line 853 of Expect.pm - which I realize is a drastic step. >> >>What am I doing wrong? Why would expect decide to close my filehandle? >>What can I do about it so that I do not have to modify the Expect.pm >>program. this works as intended, the other side (spwaned program) has closed its stdout, which normally is an indication that the program exits. if you need a more fine-grained control over the input and output streams, take a look at IPC::Run. >> >>Any help would be greatly appreciated. > > > > This sounds familiar to me...something about been there and done that. > Of course this may not be your problem. > > I simply didn't understand that to cause Expect to wait forever on > a pattern match the perl 'undef' function has to be used in place of > a $timeout value. What I did was just not define it and it didn't do > what I Expect'd. > > my $proghandle = new Expect; > $proghandle = Expect->spawn($myprog); > $proghandle->expect(undef, $whatiamexpecting); > > > It may make sense to modify the docs slightly to point out that the > perl function undef should be specified. > > > perldoc Expect > > "Simple interface: > > Given $timeout in seconds Expect will wait for $object's handle to > produce one of the match_patterns. Due to o/s limitations $timeout > should be a round number. If $timeout is 0 Expect will check one > time to see if $object's handle contains any of the match_patterns. > If $timeout is undef Expect will wait forever for a pattern to > match." > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |