Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Expect doesn't work as Expected

by jethro (Monsignor)
on Jul 08, 2012 at 13:37 UTC ( #980585=note: print w/replies, xml ) Need Help??

in reply to Re^2: Expect doesn't work as Expected
in thread Expect doesn't work as Expected

You should use $exp->log_file to log the debug output to a file instead of to STDOUT while running the script in apache. Look for differences in the log to what you see in the log when you execute it on the command line/terminal

Getting eof probably means that the mod_perl version of the script doesn't get any output from the units script. Do you see the output maybe in your browser page (highly unlikely)?

Very important: Check apache log files for any hints of what is happening

Expect FAQ says this:

Is it possible to use threads with Expect?

Basically yes, with one restriction: you must spawn() your programs in the main thread and then pass the Expect objects to the handling threads. The reason is that spawn() uses fork(), and perlthrtut:

"Thinking of mixing fork() and threads? Please lie down and wait until the feeling passes."

If your apache uses threads instead of forks, this might be a problem. I'm not sure about apache, on linux it should probably use fork (if you do "ps -ef" on the command line, you should see multiple lines with "httpd" or "apache"). On windows it probably uses threads

As a test you could change the execution of "units" to a simple "echo you have" and look at the log output. If that changes anything your apache seems to have problems executing units. But then you should have found out about this in the log files, so this test is just to make double sure it is not the units program that is the problem

You could ask the mailing list mentioned in the documentation (expectperl-discuss) if they know whether expect is generally working or not working in mod_perl

Replies are listed 'Best First'.
Re^4: Expect doesn't work as Expected
by keenlearner (Acolyte) on Jul 10, 2012 at 03:10 UTC

    Hi Thanks for your help,

    Basically yes, with one restriction: you must spawn() your programs in the main thread and then pass the Expect objects to the handling threads.

    I will try that

    and will ask the mailing list once I got the time.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980585]
talexb admires the shimmering pool after an enjoyable hour-long All Hands meeting spent listening with one ear and reading Perlmonks with the other .. ear.
[talexb]: Used all my votes during that meeting .. been a while since I've done that. Now, back to work. Good localtime, monks!
[Corion]: talexb: You enjoyed the All Hands meeting in the pool?!
[Corion]: I understand "surfing" in the pool ;)
[talexb]: Corion I admired the pool .. I wasn't .. soaking in it. ;)
[talexb]: Plus, I've been awy from PM for about three weeks .. needed a bit of catch-up time.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2017-07-20 15:11 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (304 votes). Check out past polls.