Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .