Search code examples
pythonshellsubprocesspopen

Python create a Popen shell command list


Please can someone help me create a Popen command line list from this...

identify  -format %b:%w:%h:%r:%# myimage.jpg

I have this:

cmd=Popen(['identify -format', '%b:%w:%h:%r:%#', 'myimage.jpg'])

But that does not work. the original command line works fine in the command line. But just cannot get it working in python this way.


Solution

  • try this:

    cmd=Popen(['identify', '-format', '%b:%w:%h:%r:%#', 'myimage.jpg'])
    

    you have to break down args as a list of separate arguments