Thread: Calling external apps

  1. #1
    Registered User
    Join Date
    Apr 2004

    Calling external apps

    I'm going to start developing a linux wifi app and i want to be able to do it in more of a scripting format such as calling an outside program such as iwconfig or grep. I mainly a C# develop where you can invoke the Process.Start() method but am not familiar with anything similar in C++.


  2. #2
    Registered User
    Join Date
    Aug 2004
    You can use the system() function. You pass that a command just as you would on the command line and it will execute it. I'm not sure how the function you mentioned in C# works, but I'm pretty sure this one waits for the command to complete before returning. So if the command takes a while to run your program may be stuck waiting for a while.

    Another options is to start a process. Which is going to be different on every platform. This will launch a specific executable, not run a command so calling shell functions won't work.

    On Linux you use the functions fork() and exec(). Just read their man pages for the specifics. You call fork() to have your program create a new process then exec() to launch the executable you want to run.

    On Windows you call CreateProcess(). You read up on it on MSDN here.

  3. #3
    Registered User
    Join Date
    Nov 2004

    anytime I've ever needed to do that I've just called system("open name_of_program") and the linux terminal will take care of whatever format the program needs to be run in.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Copy Registry and Calling an external apps!
    By xxxrugby in forum C Programming
    Replies: 3
    Last Post: 01-27-2005, 03:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM