which exec() to use...?

This is a discussion on which exec() to use...? within the C Programming forums, part of the General Programming Boards category; I have to make a C program in Unix that parses user input to check for valid Unix commands and ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    12

    which exec() to use...?

    I have to make a C program in Unix that parses user input to check for valid Unix commands and executes them using exec(). I have completed the parser function and its working perfectly fine for the four commands that I have to make it for. For the exec() part, I looked up and found the execl() to be pretty good but the trouble with it is that since we have to define the directory to call it, we can use a command like "ls" but when a switch is added to it like "ls -a", a string containing this command cannot be used with execl(), as only ls library will be called at a time! Can anyone suggest a good exec() variation for this purpose, which simple executes a given string in the program in Unix? Thanks!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Did you notice all those argv arguments to execl? Do you think that if you want to pass argv's to ls (or whatever) maybe you should use them?

    And I fail to see what this has to do with specifying directories.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to force a function to never return...like exec() does it
    By creeping death in forum C Programming
    Replies: 7
    Last Post: 03-28-2009, 01:08 PM
  2. Exec functions
    By Yannick in forum C Programming
    Replies: 15
    Last Post: 01-03-2009, 10:05 AM
  3. Memory freeing after exec call?
    By Sethiorth in forum C Programming
    Replies: 4
    Last Post: 10-02-2004, 03:59 PM
  4. Running 'exec' twice in one UNIX shell script
    By Zughiaq in forum Tech Board
    Replies: 2
    Last Post: 05-03-2003, 12:04 AM
  5. problem with an array of strings in C
    By ornamatica in forum C Programming
    Replies: 14
    Last Post: 05-01-2002, 06:08 PM

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