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
subprocess.call
can take the command to run in two ways - either a single string like you'd type into a shell, or a list of the executable name followed by the arguments.
You want the first, but were using the second
import subprocess
shellFile = open("linksNetCdf.txt", "r")
for row in shellFile:
subprocess.call(row, shell=True)
By converting your row
into a list containing a single string, you're saying something like "Run the command named echo these were supposed to be arguments
with no arguments"
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)