[Tutor] Running a dos program with python

Armstrong, Richard J. rarmstro at water.ca.gov
Wed Mar 10 22:20:19 CET 2010


Hello all,

 

This is my first post to the Tutor at python.org mailing list. I am in the
process of switching from Matlab to Python and there is one task that I
am having a hard time doing and cannot find the answer on the web. I
want to write a script in python that will open up a windows dos
program, send three inputs (file names) into program and then run it. I
know one way to open up the dos program with
os.system(r"c:\shake91.txt") but cannot do the rest.

 

When I run my script

 

import os

os.system(r"c:\shake91.exe")

 

In the IPython(x,y) console I see:

 

------------------------------------------------------------------------
------------------

*****************************************************

 * SHAKE  --   A COMPUTER PROGRAM FOR EARTHQUAKE RESPONSE  *

 *             ANALYSIS OF HORIZONTALLY LAYERED SITES      *

 *             by: Per B. Schnabel & John Lysmer -- 1970   *

 * ------------------------------------------------------- *

 * shake85     IBM-PC version of SHAKE                     *

 *             by: S.S. (Willie) Lai, January 1985         *

 * ------------------------------------------------------- *

 * shake88   : New modulus reduction curves for clays added*

 *             using results from Sun et al (1988)         *

 *             by: J. I. Sun & Ramin Golesorkhi            *

 *             February 26, 1988                           *

 * ------------------------------------------------------- *

 * SHAKE90/91: Adjust last iteration; Input now is either  *

 *             Gmax or max Vs; up to 13 material types can *

 *             be specified by user; up to 50 Layers can   *

 *             be specified; object motion can be read in  *

 *             from a separate file and can have user      *

 *             specified format; Different periods for     *

 *             response spectral calculations; options     *

 *             are renumbered; and general cleanup         *

 *             by: J. I. Sun, I. M. Idriss & P. Dirrim     *

 *             June 1990 - February 1991                   *

 * ------------------------------------------------------- *

 * SHAKE91   : General cleanup and finalization of input/  *

 *             output format ... etc                       *

 *             by: I. M. Idriss                            *

 *             December 1991                               *

 ***********************************************************

   Name of Input File =

------------------------------------------------------------------------
------------------

 

And there is a blinking cursor after Name of Input File. At this point I
can manually enter in the file name (and the two other remaining file
names) and then press enter and the program does run. What I really want
though is to be able to do the whole thing with a python script.

 

Any ideas?

 

Thanks

 

Richie

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100310/0c903c3e/attachment.html>


More information about the Tutor mailing list