How to insert values command will ask for before executing it

Discussion in 'macOS' started by jackhdev, Aug 10, 2012.

  1. jackhdev macrumors 6502

    Joined:
    Apr 9, 2011
    Location:
    Bismarck, North Dakota
    #1
    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
     
  2. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #2
    echo each parameter followed by a newline.

    For example:
    Code:
    echo -e "${param1}\n${param2}" | openssl...
     
  3. jackhdev thread starter macrumors 6502

    Joined:
    Apr 9, 2011
    Location:
    Bismarck, North Dakota
    #3
    I tried that and it didn't work. I'll have to look into "expect."
     
  4. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #4
    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.
     
  5. jackhdev thread starter macrumors 6502

    Joined:
    Apr 9, 2011
    Location:
    Bismarck, North Dakota
    #5
    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 ...
     

Share This Page