You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Wim Kerkhoff <wi...@merilus.com> on 2000/11/08 03:35:25 UTC

running an expect script under mod_perl

Hi Everyone,

I've been bashing my head over this problems for the last couple of
days, so I thought I'd post and see if anybody has experienced something
similiar, and what they've done to solve it.

Basically, I have an Apache::Registry script that creates an expect
script, then executes it and reads its output.  This script works just
fine from the command line.  The CGI runs fine when called from Netscape
(Linux or Windows).  However... when the CGI is called by Internet
Explorer, it hangs the CGI.  I've tried lots of different things, but
I'm still not sure whether mod_perl, the expect script, or my code is to
blame.  I have pored through the guide, the mailing list archives, man
pages, and google, but didn't find anything related to this problem.

The relevant part of the process list when the expect/cgi script hangs:

14597 ?        S      0:32 /usr/local/apache/bin/httpd -DSSL
26476 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26499 ?        S      0:00  |   \_ /usr/bin/expect
/tmp/file6rqoCY.expect
26500 ttyp9    S      0:00  |       \_ /usr/bin/expect
/tmp/file6rqoCY.expect
26501 ttyp9    S      0:00  |           \_ sh -c /bin/stty sane <
/dev/ttyp9
26502 ttyp9    S      0:00  |               \_ /bin/stty sane
26478 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26479 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26482 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26483 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26484 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26485 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26521 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26529 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26531 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
26584 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL

The expect script: (called with /usr/bin/expect /tmp/file6rqoCY.expect)

spawn /usr/bin/openssl smime -sign -in /tmp/fileicFBlw -signer
verisign.pem -to wim@merilus.com -from wim@merilus.com -subject "Testing
openssl"
expect "phrase:"
send "thepassphrase\r\n"
expect


to get the output of this, I have code that looks like this:

open (EXPECT, "/usr/bin/expect /tmp/file6rqoCY.expect < /dev/null |")
|| die $!;
while (my ($line) = (<EXPECT>)) {
    print "got: $line";
}
close (EXPECT);

As far as I can tell, the CGI (when called by IE) hangs when getting
input.  It appears to be trying to get input from /dev/ttypX, which of
course won't work because it is running in an Apache environment.

Is there a way to force the TTY to /dev/null?

Thanks,

Wim Kerkhoff, Software Engineer
Merilus Technologies, Inc.
wim@merilus.com


Re: running an expect script under mod_perl

Posted by Research System <re...@merilus.com>.
Ok, I think I figured out what was causing my problem here.

After much trial and error, I figured out that this was only happening
with HTTPS under IE.  Copying my Apache::Registry script from where it
was to this <Directory> made it work:

<Directory "/usr/local/apache/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

Apparently this sets up the environment correctly.

Still very strange, but hopefully it'll work smoothly from now on.

Wim Kerkhoff wrote:
> 
> Hi Everyone,
> 
> I've been bashing my head over this problems for the last couple of
> days, so I thought I'd post and see if anybody has experienced something
> similiar, and what they've done to solve it.
> 
> Basically, I have an Apache::Registry script that creates an expect
> script, then executes it and reads its output.  This script works just
> fine from the command line.  The CGI runs fine when called from Netscape
> (Linux or Windows).  However... when the CGI is called by Internet
> Explorer, it hangs the CGI.  I've tried lots of different things, but
> I'm still not sure whether mod_perl, the expect script, or my code is to
> blame.  I have pored through the guide, the mailing list archives, man
> pages, and google, but didn't find anything related to this problem.
> 
> The relevant part of the process list when the expect/cgi script hangs:
> 
> 14597 ?        S      0:32 /usr/local/apache/bin/httpd -DSSL
> 26476 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26499 ?        S      0:00  |   \_ /usr/bin/expect
> /tmp/file6rqoCY.expect
> 26500 ttyp9    S      0:00  |       \_ /usr/bin/expect
> /tmp/file6rqoCY.expect
> 26501 ttyp9    S      0:00  |           \_ sh -c /bin/stty sane <
> /dev/ttyp9
> 26502 ttyp9    S      0:00  |               \_ /bin/stty sane
> 26478 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26479 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26482 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26483 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26484 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26485 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26521 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26529 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26531 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 26584 ?        S      0:00  \_ /usr/local/apache/bin/httpd -DSSL
> 
> The expect script: (called with /usr/bin/expect /tmp/file6rqoCY.expect)
> 
> spawn /usr/bin/openssl smime -sign -in /tmp/fileicFBlw -signer
> verisign.pem -to wim@merilus.com -from wim@merilus.com -subject "Testing
> openssl"
> expect "phrase:"
> send "thepassphrase\r\n"
> expect
> 
> to get the output of this, I have code that looks like this:
> 
> open (EXPECT, "/usr/bin/expect /tmp/file6rqoCY.expect < /dev/null |")
> || die $!;
> while (my ($line) = (<EXPECT>)) {
>     print "got: $line";
> }
> close (EXPECT);
> 
> As far as I can tell, the CGI (when called by IE) hangs when getting
> input.  It appears to be trying to get input from /dev/ttypX, which of
> course won't work because it is running in an Apache environment.
> 
> Is there a way to force the TTY to /dev/null?
> 
> Thanks,
> 
> Wim Kerkhoff, Software Engineer
> Merilus Technologies, Inc.
> wim@merilus.com