LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2005, 05:49 AM   #1
sceadu
Member
 
Registered: Jan 2003
Posts: 76

Rep: Reputation: 15
Asking a C program to call a bash script


Hmm....I have never done this before.

Can I code a C program to run a script when certain condition occurs?
If yes, can someone kindly post an example.

Many thanks in advance.
 
Old 07-28-2005, 06:26 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Doesn't "system" do that?

Code:
#include <stdlib.h>

int runSomething;

runSomething = system ( ls );
...
this is just a guess and clearly won't compile either
 
Old 07-28-2005, 07:01 AM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,161
Blog Entries: 4

Rep: Reputation: 136Reputation: 136
That should be
Code:
int returnvalue = system ("ls");
Argument is a const char *

 
Old 07-28-2005, 08:37 PM   #4
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Ah, thanks Harishankar
 
Old 07-28-2005, 09:52 PM   #5
sceadu
Member
 
Registered: Jan 2003
Posts: 76

Original Poster
Rep: Reputation: 15
thanks
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
export call in bash script Donald1000 Linux - Software 10 03-12-2009 09:03 PM
Bash Script - How do I make sure my program is still running? nro Linux - Newbie 4 08-28-2005 02:57 PM
call a c program in a shell script jagman Programming 4 04-05-2005 05:58 PM
How to Call a C program from Perl CGI Script anoop_cn Programming 1 05-11-2004 05:37 PM
Urgent: Call a C program through Linux shell script nuwandee Programming 14 04-10-2004 08:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration