Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output from command prompt

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How might one go about redirecting the output from a program running in the dos prompt to the exec'ing program...

eg exec(program...) and VIEW the output in a kind of custom dos prompt... is this possible? it must be, everything else is ;)
 
Off the top of my head, you could redirect the output to a file. Then have the executing program read the file. Maybe something like
Code:
exec(program > output.txt);
ifstream InFile;
InFile.open(output.txt);
if (InFile)
{
    string Line;
    while (getline(InFile, Line))
    {
        cout << Line;
    }
}

This is off the top of my head so take that for what it's worth. There are probably easier ways.

James P. Cottingham
 
It is possible... If you are going to send to another DOS prompt program you can do it this way! (but I strongly advice that you modify it) just something I mixed up a second ago!


int main(int argc, char* argv[])
{
cout << &quot;Value received from another program is: '&quot; << endl;
for(int i=1 ; i<argc ; i++)
cout << &quot;(&quot; << argv << &quot;)&quot;;
execv(&quot;project2.exe&quot;, argv);
return 0;
}

int execv(char *path, char *argv[]); Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
Xaner Software, DB programer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top