Thread: which exec() to use...?

  1. #1
    Registered User
    Join Date
    Sep 2008

    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
    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 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, 11: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