Subprocess in Python: File Name too long

前端 未结 2 695
臣服心动
臣服心动 2021-02-19 20:36

I try to call a shellscript via the subprocess module in Python 2.6.

import subprocess

shellFile = open(\"linksNetCdf.txt\", \"r\")

for row in shellFile:
    s         


        
2条回答
  •  清酒与你
    2021-02-19 21:23

    You need to tell subprocess to execute the line as full command including arguments, not just one program.

    This is done by passing shell=True to call

     import subprocess
     cmd = "ls " + "/tmp/ " * 30
     subprocess.call(cmd, shell=True)
    

提交回复
热议问题