C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-16-2006, 06:10 AM   #1
Registered User
 
Join Date: Apr 2005
Posts: 6
embedding shell comands in c code

could anyone point me towards a tutorial that show me how to embed bash shell commands in c. i know it can be done in perl but my assingment is in c. I've tried google but after an hour of sifting thru it i've come up with nothing.

thanks,
Dave

Last edited by docetes; 03-16-2006 at 06:35 AM.
docetes is offline   Reply With Quote
Old 03-16-2006, 06:35 AM   #2
Registered User
 
Join Date: Apr 2005
Posts: 6
found an example

Code:
#include <stdio.h>
#include <stdlib.h>

#define SHELLSCRIPT "\
for ((i=0 ; i < 10 ; i++))\n\
do\n\
echo \"Count: $i\"\n\
done\n\
"

int main() 
{
	puts("Will execute sh with the following script :");
	puts(SHELLSCRIPT);
	puts("Starting now:");
	system(SHELLSCRIPT);
	return 0;
}
docetes is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enforcing Machine Code Restrictions? SMurf Tech Board 21 03-30-2009 07:34 AM
Values changing without reason? subtled C Programming 2 04-19-2007 10:20 AM
Obfuscated Code Contest Stack Overflow Contests Board 51 01-21-2005 04:17 PM
Updated sound engine code Bubba Game Programming 8 11-18-2004 12:38 PM
Interface Question smog890 C Programming 11 06-03-2002 05:06 PM


All times are GMT -6. The time now is 09:57 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22