How to execute shell command in Python program?
Madhavan Bomidi
blmadhavan at gmail.com
Sat Jul 20 09:38:28 EDT 2019
Hi,
I have the following shell commands to run my executable created with gfortran:
-----------------------------------------------------------------------------
$ pwd
/OPAC/opac31a/opac31
$ 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
READY.
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
subprocess.call(['./opac'],shell=True)
Out[21]: 2
I am not able to know how I input the 'opac' (which is the input filename)
Please help me.
More information about the Python-list
mailing list