Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run $(Linux commnad) in a Python subprocess.run?

I run:

proc = subprocess.run(["echo", "$(echo 1111dGUv+rG551123eFwBhCMde6BIS90c3AAAAA= | base64 -d)"], check=True, stdout=subprocess.PIPE)
print(proc.stdout)

Got:

b'$(echo 1111dGUv+rG551123eFwBhCMde6BIS90c3AAAAA= | base64 -d)\n'

But wish to have $(echo 1111dGUv+rG551123eFwBhCMde6BIS90c3AAAAA= | base64 -d) executed and then passed to echo within a subprocess.run. So the result could be:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

�]ute/����]v��p�u�!/tsp

How could this be achieved in subprocess.run() ?

>Solution :

Pass the shell=True argument to the subprocess.run() function, like this:


proc = subprocess.run('echo "$(echo 1111dGUv+rG551123eFwBhCMde6BIS90c3AAAAA= | base64 -d)"', 
                      shell=True, 
                      check=True, 
                      stdout=subprocess.PIPE)
print(proc.stdout)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading