Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I don't think I properly understand the "expect" utility.

While searching for a way to automate a build process that involves jar signing, I came across expect, and thought I could use it to supply a password to jarsigner (whether having a password in a shell script is a good idea I understand the risks of).

expect "Enter Passphrase for keystore:"

Instead of catching this, the jarsigner sat waiting at that line.

Am I completely misunderstanding the point of "expect" and if I am, what can I use to achieve this effect?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

I think it would expect to see a greater context of your code. But I would think something along these lines should work:

expect -c "spawn jarsigner <options here> ; expect \"Enter Passphrase for keystore:\" ; send $PASSWORD\n ; interact"

share|improve this answer
add comment

First of all, are you sure the jarsigner doesn't have a way of supplying that from the command line option or a configuration file? If not, expect is a good last resort. Make sure you spawn the subprocess (jarsigner) using a pty, not a pipe. Some apps, especially those asking for a password, use the tty device in raw mode and expect a tty interface.

Then, after expect you have to send the password.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.