I am currently working on moving some bash scripts over to C, and one of them call's an external python script, so for instance ./remoteclient01a.py "remotecommand player /something something"
./remoteclient01a.py "remotecommand player /something something"
and Ive been looking for a way to execute this command in C, but Im not really sure as to which I should use, being that System() seems to be the best one, but then a few pages say that it is a bad choice in some cases, so if someone could recommend a method to do this I would really appreciate it, thanks!
The only portable ways to do this in C are system and popen. The function popen allows you to read output from the command.
From the man page
The popen() function opens a process by creating a pipe, forking and involking the
shell.
There are other means to call an external program in C. See the following tutorial explaining all the ways :
Executing programs with C(Linux)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With