How to insert values command will ask for before executing it

jackhdev

macrumors 6502
Original poster
Apr 9, 2011
343
0
Bismarck, North Dakota
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:

Code:
echo sudopassword | sudo rm -rf /file.txt;
How can I add all three values in one shot? Thanks
 

calderone

macrumors 68040
Aug 28, 2009
3,679
86
Seattle
echo each parameter followed by a newline.

For example:
Code:
echo -e "${param1}\n${param2}" | openssl...
 

jackhdev

macrumors 6502
Original poster
Apr 9, 2011
343
0
Bismarck, North Dakota
Should work fine, I have used this technique in a number of scripts, one that generates certs as well :)

Expect should do the trick though.
Really? Could you put give me the same thing you gave me above, but set the passwords to "test"?

Should it be: echo -e "$test\n$test\n$test" | openssl ...