Thread: Commands

  1. #1
    Registered User
    Join Date
    Apr 2008


    hello, i am trying to emulate execution of multiple commands like what the shell does. i have some concepts in mind and i hope u guys can correct me if im wrong.

    example command: ls -a | sort

    Find out if any piping is needed by looping the string to find "|"
    Set pipeFlag as 1
    Create Pipe // pipe(p)
    If Under Parent
    If pipeFlag then
    Close Downstream
    Connect Upstream to pipe (dup2(p[0])
    Close Upstream
    Execute command ls -a
    Wait for child to finish....
    end if
    Else Underchild
    If Pipeflag then
    Close Upstream
    Connect downstream to pipe(dup2(p[1])
    Close downstream
    execute sort
    end if
    execute other commands normally
    i would like some advice on how i could split up the string for the commands. appreciate any help. thanks.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    strtok, strchr are both useful to split strings.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get user commands from text file.
    By Ironic in forum C Programming
    Replies: 4
    Last Post: 12-08-2008, 11:38 PM
  2. Replies: 2
    Last Post: 07-27-2007, 12:48 PM
  3. Executing system commands cross platform
    By markucd in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2005, 08:56 AM
  4. Disable ALT key commands
    By Lionmane in forum Windows Programming
    Replies: 9
    Last Post: 09-23-2005, 10:41 AM
  5. Bluetooth Dial-up network profile with AT commands
    By BrownB in forum Networking/Device Communication
    Replies: 0
    Last Post: 06-29-2005, 02:47 AM