[Expect] Calling Expect Script Using Exec in PHP
by Hadassa Golovenshitz other posts by this author
Jun 23 2008 11:44PM messages near this date
view in the new Beta List Site
Re: [Expect] Scripting SSH with Activestate Expect and TCL...'?' chars inserted in terminal
|
[Expect] Building expect on tru64 unix 5.1b
Hi,
First of all, thanks so much for taking the time to help me.
I am trying to call an expect script from php using the exec function. I am
able to call other shell scripts, so I see that the exec function is working
as expected.
The script I am running works from the command line, but hangs every time I
try to call it from the browser in php. I saw a similar post by Fabian Borot
in 2005, and followed the suggestions there. They helped me progress, but
not get all the way there!
I suspect that the problem is occurring when the script expects are prompt -
what would the prompt that php 'sees' look like? I've tried to make the
prompt more general by putting only the end of it in, and like I said it
does work on the command line.
Does anyone have any idea what I can change?
Here is the active part of the expect script: (I've replaced sensitive
information with xxx)
set timeout -1
#spawn $env(SHELL)
spawn /bin/bash
match_max 100000
expect -exact " easy-rsa\]# "
send -- ". ./vars\r"
expect -exact " easy-rsa\]# "
send -- "./build-key $argv\r"
expect -exact "
Country Name (2 letter code) \[xxx\]:"
send -- "xx\r"
expect -exact "US\r
State or Province Name (full name) \[xx\]:"
send -- "xxxx\r"
expect -exact "xxxxx\r
Locality Name (eg, city) \[NY\]:"
send -- "NY\r"
expect -exact "NY\r
Organization Name (eg, company) \[xxxx\]:"
send -- "xxxx\r"
expect -exact "xxxxx\r
Organizational Unit Name (eg, section) \[\]:"
send -- "$argv\r"
expect -exact "$argv\r
Common Name (eg, your name or your server's hostname) \[\]:"
send -- "$argv\r"
expect -exact "$argv\r
Email Address \[xxxx@xxxx\]:"
send -- "$argv\r"
expect -exact "$argv\r
\r
Please enter the following 'extra' attributes\r
to be sent with your certificate request\r
A challenge password \[\]:"
send -- "\r"
expect -exact "\r
An optional company name \[\]:"
send -- "\r"
expect -exact "(3650 days)\r
Sign the certificate? \[y/n\]:"
send -- "y\r"
expect -exact "y\r
\r
\r
1 out of 1 certificate requests certified, commit? \[y/n\]"
send -- "y\r"
expect -exact " easy-rsa\]# "
send -- "exit\r"
expect eof
Thanks so much for your help!!
Hadassa
|