[Pythonmac-SIG] reposting: Q: emulating os.system() on macs?

Giorgio Brajnik giorgio@dimi.uniud.it
Thu, 2 Dec 1999 14:52:23 +0100 (MET)


Thanks a lot, Jack. 

  > I'm afraid this is impossible, as MacOS has no concept of stdin/stdout/stderr. 
  > You can make this work for some applications, on a per-application basis, but 
  > there is no general solution.

I suspected that os.system() couldn't be implemented directly on
Macs. What I was looking for is some method (perhaps based on
AppleScript, and/or some sort of launch() routines) to obtain the same
result. I'm very happy with Python, and consider it a beatiful and
effective glue language. But PythonMac falls short on this aspect if
there are no easy ways to let two separate applications talk.
  > 
  > If you can give some details on the program you're trying to execute someone 
  > here may be able to come up with a solution that'll work for this particular 
  > case.

I'm willing to remove the distinction between stdout and stderr, but
still need to launch a batch application on an input file, wait its
termination and read its results from a file.

[BTW, the application I need to run is nsgmls, a SGML-based validator
(http://www.jclark.com/sp/). ]
  > 
  > > I'm in the process of planning to port a Python application that
  > > is being developed on Linux to the Mac. One of the many questions I
  > > have is how to emulate in Python/Mac something like:
  > > 
  > > 
  > > def doit(infile, outfile, errfile, exefile):
  > >     """
  > >     execute "exefile" on "infile" and write "outfile" and "errfile"
  > >     """
  > >     cmd = '%s < "%s" > "%s" 2> "%s"'%(exefile, infile, outfile, errfile)
  > >     os.system(cmd)
  > >     return (outfile, errfile)
  > 

        Giorgio Brajnik
______________________________________________________________________
Dip. di Matematica e Informatica   | voice: +39 (0432) 55.8445
Universita` di Udine               | fax:   +39 (0432) 55.8499
Via delle Scienze, 206             | email: giorgio@dimi.uniud.it
Loc. Rizzi -- 33100 Udine -- ITALY | http://www.dimi.uniud.it/~giorgio