Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I know that os.popen will be replaced by subprocess, But I don't know how to convert

os.popen('swfdump /tmp/filename.swf/ -d')

to the subprocess.popen()

I also tried:

subprocess.Popen("swfdump /tmp/filename.swf -d")

subprocess.Popen("swfdump %s -d" % (filename))  # NOTE: filename is a variable

                                                # containing /tmp/filename.swf

But, I'm not getting this. Anyone please help me. Thank you

1 Answer

0 votes
by (26.4k points)

Subprocess.popen will takes a list of arguments:

from subprocess import Popen, PIPE

process = Popen(['swfdump', '/tmp/filename.swf', '-d'], stdout=PIPE, stderr=PIPE)

stdout, stderr = process.communicate()

Even this documentation helps users convert from os.popen to subprocess

Want to learn the concepts of python in detail? Join the Python course fast!!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...