Nov-22-2019, 02:32 AM
(This post was last modified: Nov-22-2019, 02:53 AM by larkypython.)
I would like the python test.py to run a program after it been compiled to a.out and to read test.dat file:
How can I do this? Thanks.
So no one ever encountered this problem?
import subprocess import os cmd='./a.out' subprocess.call(cmd, shell=True) cmd='test.data' subprocess.call(cmd, shell=True)the c++ program is in the test.cpp file:
#include <iostream> #include <string> using namespace std; int main() { string filename(""); cout<<"Please enter the file name:"<<endl; cin>>filename; cout<<"File name is: "<<filename<<endl; return 0; }execute python test.py, and it stuck there, and looks like the program are waiting for me to input 'test.data', the second subprocess.call seems not working.
How can I do this? Thanks.
So no one ever encountered this problem?