-   Programming (
-   -   Running shell script within a C or C++ program (

Quantum0726 06-14-2005 12:30 AM

Running shell script within a C or C++ program
Hi, I have a shell script that I'd like to execute from within a C++ program. For example, I need to access the man command, the redirection operator, and a command that converts a ps file to a pdf. If I can run my bash script from within a C++ binary this would take care of it. So would running each command from within the C++ program. I could also probably do this in C, but I'm not as familiar with C as I am with C++.

Thanks much!

uman 06-14-2005 12:42 AM

Make sure you've included cstdlib.

then do this:


if your batch file is in the path you can do


system(const char*); basically runs an executable.

Quantum0726 06-15-2005 09:14 PM

Thanks, that worked great!

All times are GMT -5. The time now is 04:49 AM.