Ask Different is a question and answer site for power users of Apple hardware and software. 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'm trying to convert a P12 file to a PEM file. When I execute the command, the terminal asks me for three things:

P12 passphrase (I type it in, hit enter)
PEM passphrase (type it in, hit enter)
PEM passphrase confirm (type it in, hit enter)

I know I can execute a sudo command all in one shot by using the following:

echo sudopassword | sudo rm -rf /file.p12;

How can I add all three values in one shot?

share|improve this question
... just don't lose the file.txt from the end of that command. – bmike Aug 11 '12 at 4:06
@bmike Thanks for responding, but could you be more clear? Should I do something like echo password | echo password | echo password | normal command? – Jack Humphries Aug 11 '12 at 4:07
up vote 1 down vote accepted

The canonical unix tool for this job is expect.

Here is a short tutorial that should get you going on scripting a series of passwords to be entered when the appropriate prompt is detected by the tool.

share|improve this answer

Your Answer


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.