Pyhton script to call another program

B

Ben Keshet

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!
 
D

Diez B. Roggisch

Ben said:
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!

Check out the module "subprocess" in the standard library documentation.
This will allow you to call other programs.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top