Good. Thanks.
Here's my code.
==========
# Executing a Linux program under Win XP
from subprocess import call
myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"])
==========
But msgs are produced ...
Traceback (most recent call last):
File
"C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/fun-subprocess_Linux.py",
line 4, in <module>
myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"])
File "C:\Python25\lib\subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python25\lib\subprocess.py", line 594, in __init__
errread, errwrite)
File "C:\Python25\lib\subprocess.py", line 816, in _execute_child
startupinfo)
WindowsError: [Error 5] Access is denied
I looked for the attributes on the file and it shows "A". I'm the admin
on my XP Pro, and the file is owned by Admin.
wolf is a 1 meg file.
Alan Gauld wrote:
"Wayne Watson" <sierra_mtnv...@sbcglobal.net> wrote
What is meant by "The arguments are the same
as for the Popen constructor.",
in Convenience Functions? In fact, what is such a function?
It means that there is a function which takes the same arguments
as the __init__() method of the Popen class.
They are convenience functions in that you don't need to create the
class
to use them you can just call them directly. THe payoff is that you
lose
some of the flexibility of using the class, but often you don;t need
that.
class subprocess.Popen(args, bufsize=0,
executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None,
close_fds=False ....
Why not just class Popen instead of subprocess.Popen?
The notation is saying that there is a class defined in the
subprocess module called Popen with a constructor that
has the listed parameters. It is just a shorthand way of
expressing that.
In practice you would create an instance with either:
import subprocess
p = subprocess.Popen(....)
OR
from subprocess import Popen
p = Popen(....)
Is there a suggestion here that I need only
do:
from subprocess import Popen
myProg=Popen()
myProg.call("wolf", "-h")
Even simpler, you only need:
from subprocess import call
myProg = call(["wolf", "-h"])
You need to put the command as the first entry of a list and each
argument as a separate entry
HTH,
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
“Life is one damn thing after another."
-- Mark Twain
|