[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to execute shell command in Python program?


I have the following shell commands to run my executable created with gfortran:
$ pwd
$ ls
extback.dat	opac		opac.f		result		terr.dat
input		opac.cfg	pyopac3.py	solar.dat	wel.dat
$ ./opac                             <======
 *  Optical Properties of Aerosols and Clouds OPAC 3.1  *
 *  --------------------------------------------------  *
 *                                                      *
 *  The contents of OPAC has been described in:         *
 *  M. Hess, P. Koepke and I. Schult (1997):            *
 *       "Optical Properties of Aerosols and Clouds:    *
 *        The software package OPAC"                    *
 *  submitted to Bull. Am. Meteor. Soc.                 *
 *                                                      *
 *  last update: 14.11.97                     M. Hess   *

  name of input file (without extension .inp), (max. 8 characters)
  default: opac.inp
opac                                     <======
  input file input/opac.inp     used
Note: The following floating-point exceptions are signalling: IEEE_DENORMAL

Now my concern is the following commands (pointed by <======) to be run within the Python program. I tried to use the following lines in the Python program:

import subprocess

Out[21]: 2

I am not able to know how I input the 'opac' (which is the input filename)

Please help me.