Thread: system();

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    46

    system();

    Correct me if Im wrong, but system(); will only do one command, so I cant do system("cd cow"), is there any function that will do this for me?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    46
    isnt there a way to pass stuff to the command line?

  3. #3
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91
    you can use argv and argc:

    Code:
    main(int argc, char *argv[]) {
    
    /* code */
    
    }

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    If this is Unix/Linux, then there is a family of functions called "exec". These functions take over a forked process, executing whatever code you put in the exec call in the new process space. I may be mistaken, but I think this is basically what system() winds up doing.

    starX
    www.axisoftime.com

  5. #5
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    you can use multiple commands in one statement to system by using semicolons

    system("cd cow ; cat udders | lpr ; rm udders");

    (well for unix you can)
    Last edited by beege31337; 11-15-2002 at 12:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Number system base M, print numbers N digits wide...
    By biterman in forum C Programming
    Replies: 12
    Last Post: 11-19-2001, 04:31 AM