Ben Keshet wrote:
Hi,

I am trying to write a simple python script to manipulate files and call other programs. I have a program installed (rocs) which I run using cygwin on my XP (but is not in python). Can I run the pyhton script and then call the other program in the same script?

For example:
Python Code  # this line opens a file
Python Code  # this line splits the file into 4 different files
rocs  # this line calls the program 'rocs' to run on the newly formed files
Python Code # this line renames rocs output files and saves them in the right place.

Otherwise, I would have to write two scripts (before and after 'rocs'), and run the 3 scripts/programs separately. I am relatively new to python and don't know a lot about cygwin. Please remember that if you try to answer me :) Thanks!
--
http://mail.python.org/mailman/listinfo/python-list

==========================================
If you don't like a lot of typing that obscures the process,
take a look at the spawn family.


 processPython 2.5.2 (r252:60911, Mar  4 2008, 10:40:55)
[GCC 3.3.6] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import os
>>> AbWd = os.spawnlp( os.P_WAIT,"abiword","abiword","")

The P_WAIT stops python until the program (abiword in this case) completes. The "" at the end are for tokens to be given to the program and yes - contrary to manual, the program MUST be there TWICE (complete with any path needed).

for windows this works:
(can't cut and paste from a dos box!###%*&!!!)

Python 2.5.1 ... on win32
>>> import os
>>> result = os.spawnl( os.P_WAIT, "d:\\winmcad\\mcad","")

Runs the program mcad. Returns to python when mcad exits.


Today: 20090506
Python ver as snippets show.
OS is Linux Slackware 10.2
OS is Windows XP Pro

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to