-
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++.
Thanks
-
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.
-
yeah
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.