Connecting Tech Pros Worldwide Help | Site Map

Quick Question

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:06 AM
Carter
Guest
 
Posts: n/a
Default Quick Question

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?

  #2  
Old July 22nd, 2005, 06:06 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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.


  #3  
Old July 22nd, 2005, 06:06 AM
Mike Wahler
Guest
 
Posts: n/a
Default 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


  #4  
Old July 22nd, 2005, 06:06 AM
Carter
Guest
 
Posts: n/a
Default Re: Quick Question

thanks
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.