I want to run a program which uses the output from another program. I tried calling system("myfile.exe")
but the executable doesn't seem to be executed. I am using cygwin. How should I run myfile.exe
from within my program?
Asked
Active
Viewed 164 times
0

naman arora
- 51
- 7
-
Can you start myfile.exe manually, outside of the first program? – deviantfan Oct 24 '15 at 12:11
-
1Possible duplicate of [How do I open a .exe in from another C++ .exe?](http://stackoverflow.com/questions/15435994/how-do-i-open-a-exe-in-from-another-c-exe) – RamblingMad Oct 24 '15 at 12:12
-
Are you sure your program isn't running? It may just seem that way because you can't see the output. – RamblingMad Oct 24 '15 at 12:17
-
@deviantfan yes, myfile.exe is running outside the program, – naman arora Oct 24 '15 at 12:18
-
@CoffeeandCode Yes, I am sure, its not running, because output of exe file has to generate some output which is not produced. – naman arora Oct 24 '15 at 12:19
-
1@namanarora you glided past my exact point. Your application might not be capturing the external applications `stdout` output. – RamblingMad Oct 24 '15 at 12:22
-
What did system() return? – Martin James Oct 24 '15 at 12:30
-
I missed the complete path, its running now after adding the complete path for myfile.exe file. – naman arora Oct 24 '15 at 12:40
1 Answers
1
In Cygwin using shell or bash scripts you can store the output of the first program into a variable.
For example we say that program1 is the "date" command and "echo" is the second program. In shell you use:
dt=
`date
`;
will put the value returned by the date command into the variable dt. (grave accent executes the code and returns the output)
echo $dt
prints the value of the variable dt

Viorel Mirea
- 371
- 3
- 6