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?

  • ... just don't lose the file.txt from the end of that command.
    – bmike
    Aug 11, 2012 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? Aug 11, 2012 at 4:07

1 Answer 1


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.

You must log in to answer this question.

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