[Tutor] Executing shell commands

Mats Wichmann mats at wichmann.us
Sat Feb 15 23:34:56 EST 2020


On February 15, 2020 8:46:28 PM MST, 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.

you dont need to run an external command to collect the files, look at the glob module and even more apropos the pathlib module.
-- 
Sent from a mobile device with K-9 Mail. Please excuse my brevity.


More information about the Tutor mailing list