![]() |
how do I call a bash script in C?
Hi,
I'm new to learning C and just wondered if theres a way I can run a bash script from a C program (so that if a certain option is selected eg with switch case then a bash script runs)? thanks :) |
You don't mention your OS/Platform. Since that's where these things get done, it would seem to be appropriate. Come back with that info. Meantime, read the forum's rules/FAQ and the "How to Post...." thread.
|
>You don't mention your OS/Platform.
I think I'll go out on a limb and say that it's a POSIX compliant platform. :rolleyes: >just wondered if theres a way I can run a bash script from a C program Yes, there is. Generally, if you ask a question along the lines of "Can C do <so and so>", the answer is almost definitely "Yes!". |
ROFL! My mental (if I may loosely define it as that) translation was 'shell/batch script' :o . My apologies to the OP.
|
Quote:
|
Hey,
OS is vector linux. sorry I dont think I explained the question very well, I want to open a bash script (.sh file) I've already written within a C program so that partway through the program it also runs the bash script. Narue - the question was more HOW can c do so and so! :) :) thanks:) |
actually system () works fine for what i'm trying to do with it, thanks very much :)
|
>Narue - the question was more HOW can c do so and so!
I know, but you'll find that programmers tend to be smartasses. If you unintentionally ask a yes or no question, you're damned sure to get a yes or no answer from at least one person. ;) |
man popen
man system man exec All of these man pages explain one way to do what you ask. Use popen if you want to get output - like stderr. |
| All times are GMT -5. The time now is 1:11 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC