expect script help - example script included

expect script help - example script included

Post by John Hal » Sat, 10 Nov 2001 08:32:43



I am using expect to submit a PEM passphrase for httpsd. I have the httpsd
script call a little expect script that starts httpsd and supplies the
password.

For some reason, although expect is starting httpsd just fine, it seems to
die right away:

________________________________________________________
[Mon Nov  5 17:07:30 2001] gcache started
[Mon Nov  5 17:07:30 2001] gcache started
[Mon Nov  5 17:07:30 2001] [notice] Apache/1.3.12 Ben-SSL/1.40 (Unix)
configured
 -- resuming normal operations
[Mon Nov  5 17:13:40 2001] [notice] caught SIGTERM, shutting down
________________________________________________________

If I start httpsd manually and enter the password manually, it starts fine
and stays alive.

My expect script resembles several example scripts that are supposed to
work; am I missing something obvious?

________________________________________________________
#!/usr/bin/expect
set pass "password"
spawn /usr/sbin/httpsd -DSSL -f /etc/httpsd/conf/httpsd.conf
set send_slow {1 .1}
expect "*rase:"
sleep .1
send "$pass\r"
expect "pid="
sleep .1
expect eof
________________________________________________________

Thanks.

 
 
 

expect script help - example script included

Post by Michael Heimin » Sat, 10 Nov 2001 16:21:50



00:32:

Quote:> I am using expect to submit a PEM passphrase for httpsd. I have the
> httpsd script call a little expect script that starts httpsd and
> supplies the password.

> For some reason, although expect is starting httpsd just fine, it
> seems to die right away:

> ________________________________________________________
> [Mon Nov  5 17:07:30 2001] gcache started
> [Mon Nov  5 17:07:30 2001] gcache started
> [Mon Nov  5 17:07:30 2001] [notice] Apache/1.3.12 Ben-SSL/1.40
> [(Unix)
> configured
>  -- resuming normal operations
> [Mon Nov  5 17:13:40 2001] [notice] caught SIGTERM, shutting down
> ________________________________________________________

> If I start httpsd manually and enter the password manually, it
> starts fine and stays alive.

> My expect script resembles several example scripts that are supposed
> to work; am I missing something obvious?

> ________________________________________________________
> #!/usr/bin/expect
> set pass "password"
> spawn /usr/sbin/httpsd -DSSL -f /etc/httpsd/conf/httpsd.conf
> set send_slow {1 .1}
> expect "*rase:"
> sleep .1
> send "$pass\r"
> expect "pid="
> sleep .1
> expect eof
> ________________________________________________________

> Thanks.

Not sure about your problem, could be a missing controlling tty,
however if you store the passphrase in a text file on your box, you
could just take it away from the cert, that would be the same and
shouldn't be done, if it's a real cert.

Michael Heiming

 
 
 

expect script help - example script included

Post by Christian Merril » Sat, 10 Nov 2001 23:15:23



Quote:> I am using expect to submit a PEM passphrase for httpsd. I have the httpsd
> script call a little expect script that starts httpsd and supplies the
> password.

> For some reason, although expect is starting httpsd just fine, it seems to
> die right away:

> ________________________________________________________
> [Mon Nov  5 17:07:30 2001] gcache started
> [Mon Nov  5 17:07:30 2001] gcache started
> [Mon Nov  5 17:07:30 2001] [notice] Apache/1.3.12 Ben-SSL/1.40 (Unix)
> configured
>  -- resuming normal operations
> [Mon Nov  5 17:13:40 2001] [notice] caught SIGTERM, shutting down
> ________________________________________________________

> If I start httpsd manually and enter the password manually, it starts fine
> and stays alive.

> My expect script resembles several example scripts that are supposed to
> work; am I missing something obvious?

> ________________________________________________________
> #!/usr/bin/expect
> set pass "password"
> spawn /usr/sbin/httpsd -DSSL -f /etc/httpsd/conf/httpsd.conf
> set send_slow {1 .1}
> expect "*rase:"
> sleep .1
> send "$pass\r"
> expect "pid="
> sleep .1
> expect eof
> ________________________________________________________

> Thanks.

might try having your expect script executed in the background.

Christian

 
 
 

expect script help - example script included

Post by Kevin Colli » Sun, 11 Nov 2001 06:22:46



> I am using expect to submit a PEM passphrase for httpsd. I have the httpsd
> script call a little expect script that starts httpsd and supplies the
> password.

> For some reason, although expect is starting httpsd just fine, it seems to
> die right away:

 - snip -

Quote:> If I start httpsd manually and enter the password manually, it starts fine
> and stays alive.

> My expect script resembles several example scripts that are supposed to
> work; am I missing something obvious?

> ________________________________________________________
> #!/usr/bin/expect
> set pass "password"
> spawn /usr/sbin/httpsd -DSSL -f /etc/httpsd/conf/httpsd.conf
> set send_slow {1 .1}
> expect "*rase:"
> sleep .1
> send "$pass\r"
> expect "pid="
> sleep .1
> expect eof
> ________________________________________________________

> Thanks.

Not sure why httpsd dies, but some expect advice:

1) if you are try to match a regular expression with "*rase:", (in
other words, not a literal '*') you need to use:

expect -re '*rase:'

or you could just use: expect 'rase:'

2) you probably do not need the 'sleep .1' in your script - just use
'send -s' since you already have send_slow set.

Good luck...

Kevin