I want to run the following command using Python on a Mac OS X computer:
openssl enc -aes-128-cbc -K $(echo -n 'blabla1' | xxd -p) -iv blabla2 -in /tmp/clair -nopad -out /tmp/crypte1 -d
Here is what I have tried:
clef = 'blabla1'
iv = 'blabla2'
arguments = ['openssl','enc', '-aes-128-cbc', '-K $(echo -n \'%s\' | xxd -p)' % clef ,'-iv' ,'%s' % iv,'-in', '/tmp/clair','-nopad','-out','/tmp/crypte1','-d']
execute = Popen(arguments, stdout=PIPE)
out, err = execute.communicate()
The command works fine from a terminal but I get an error from the Python script:
unknown option '-K $(echo -n 'blabla1' | xxd -p)'
I have tried several variants of python shell functions (os.system
for example), but I have a problem in each case.