louisroy
louisroy

Reputation: 87

Multiline Windows shell command with brackets and pipeline

I'm trying to encrypt some form data with OpenSSL on Windows and I'm having a hard time figuring out what's the correct syntax. With the following command, OpenSSL returns a PKCS7 message, but still gives me a & was unexpected at this time message.

(openssl smime -sign -signer client-public.pem -inkey client-private.pem -outform der -nodetach -binary^ 
formkey1=formvalue1^ 
formkey2=formvalue2^ 
formkey3=formvalue3^ 
^ 
^ 
) | openssl smime -encrypt -des3 -binary -outform pem server-public.pem

I feel like my pipeline is causing some problem in there but I have no idea what I should do to have a clean, error-free result.

Upvotes: 2

Views: 760

Answers (1)

jeb
jeb

Reputation: 82390

There is no need to split it into multiple lines.
So you should first test if it works on a single line.

Then you could use the multiline caret, but don't forget to add a space in the next line, else it will paste the complete text together without any delimiters.
And the caret just before the closing parenthesis, will fail, as a multiline caret escapes the first character of the next line, so your closing parenthesis will not close anything.

This should work

(openssl smime -sign -signer client-public.pem -inkey client-private.pem -outform der -nodetach -binary^
 formkey1=formvalue1^
 formkey2=formvalue2^
 formkey3=formvalue3^
 ^
 ^
 ) | openssl smime -encrypt -des3 -binary -outform pem server-public.pem

Upvotes: 3

Related Questions