LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 04: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, 05:26 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
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, 06:01 AM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

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

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

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

Original Poster
Rep: Reputation: 15
thanks
 
  


Reply



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 08:03 PM
Bash Script - How do I make sure my program is still running? nro Linux - Newbie 4 08-28-2005 01:57 PM
call a c program in a shell script jagman Programming 4 04-05-2005 04:58 PM
How to Call a C program from Perl CGI Script anoop_cn Programming 1 05-11-2004 04:37 PM
Urgent: Call a C program through Linux shell script nuwandee Programming 14 04-10-2004 07:31 PM

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

All times are GMT -5. The time now is 02:59 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
Open Source Consulting | Domain Registration