Connecting Tech Pros Worldwide Forums | Help | Site Map

Quick Question

Carter
Guest
 
Posts: n/a
#1: Jul 22 '05
How do you make the output of a c++ program be interpreted as a UNIX
command? Example, what would a program that executed ls look like?

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Quick Question


"Carter" <cjcastor@phreaker.net> wrote...[color=blue]
> How do you make the output of a c++ program be interpreted as a UNIX
> command? Example, what would a program that executed ls look like?[/color]

You should probably use 'system' function.


Mike Wahler
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Quick Question



"Carter" <cjcastor@phreaker.net> wrote in message
news:b7fc5708.0402031127.4d338b09@posting.google.c om...[color=blue]
> How do you make the output of a c++ program be interpreted as a UNIX
> command? Example, what would a program that executed ls look like?[/color]

#include <cstdlib>
#include <iostream>

int main()
{
int status = EXIT_SUCCESS;

if(system(NULL))
system("ls");
else
{
std::cerr << "Command processor not available\n";
status = EXIT_FAILURE;
}

return status;
}


-Mike


Carter
Guest
 
Posts: n/a
#4: Jul 22 '05

re: Quick Question


thanks
Closed Thread