embeddong shell comands in c code

This is a discussion on embeddong shell comands in c code within the Linux Programming forums, part of the Platform Specific Boards category; could anyone point me towards a tutorial that show me how to embed bash shell commands in c. i know ...

  1. #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 05:35 AM.

  2. #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;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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