How to excute shell command and return result string ?

Hi

I remember here is some C function which can excute shell command and return the result string .

If I give a string call "ifconfig" , the result string will contain network IP information .

Do you know this C function name ? Thank you very much .

Reply to
Kid
Loading thread data ...

Try "execve". BTW why are you executing a "ifconfig" while you can access the functionality via standard networking APIs?

Reply to
Janaka

system(3) is the high level version that runs the command via a shell for full shell redirection, etc. That sets up the pipes (file redirection) that the exec(2) family won't: you'd have to dup() stdout before exec() to get the output.

Agreed, use the direct functions when possible (no need for fork/exec other processes just to get the parameters, works faster too), but is more work for the programmer.

Reply to
Jeff Jonas

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.