[Tutor] Executing shell commands

boB Stepp robertvstepp at gmail.com
Sat Feb 15 23:14:39 EST 2020


On Sat, Feb 15, 2020 at 9:46 PM Phil <phillor9 at gmail.com> wrote:
>
> On 16/2/20 12:47 pm, boB Stepp wrote:
> Thank you Bob for your reply.
> > subprocess.call("ls", "/home/phil/Downloads/*.gpx", shell=True)
> Adding shell=True to .call() or .run() generates the following:
>
> Traceback (most recent call last):
>    File "/home/phil/Python/waypoints.py", line 6, in <module>
>      subprocess.run("ls", "/home/phil/Downloads/*.gpx", shell=True)
>    File "/usr/lib/python3.7/subprocess.py", line 488, in run
>      with Popen(*popenargs, **kwargs) as process:
>    File "/usr/lib/python3.7/subprocess.py", line 702, in __init__
>      raise TypeError("bufsize must be an integer")
> TypeError: bufsize must be an integer
>
> Anyway, you've given me something to think about, I'll experiment further.

Apparently your original approach of making a list of arguments is the
correct one, and I was sadly mistaken.  You *do* need the square
brackets.  Try that and hopefully all will be well.


-- 
boB


More information about the Tutor mailing list