How to execute an external binary reading from standard in
Eric Brunel
eric.brunel at pragmadev.com
Tue Jul 30 11:08:43 EDT 2002
Markus O Kaukonen wrote:
> Dear all,
>
> How to execute a exeternal (binary) program reading from standard input
> in a python code ?
> For example : /home/mok/my_prog.bin < my_input.txt
>
> My system is Linux and the binary is written originally in fortran 90
> (if that should matter).
>
> I tried
> os.popen('/home/mok/my_prog.bin < my_input.txt ')
> with no success
No need for popen here. Doing a:
os.system('/home/mok/my_prog.bin < my_input.txt ')
should work.
You may also do it "by hand" by doing:
p = os.popen('/home/mok/my_prog.bin', 'w')
p.write(open('my_input.txt').read())
p.close()
which is exactly the same thing as above, but done with Python. But the
os.system above really should work...
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list