C: Run a System Command and Get Output?
You want the "popen" function. Here's an example of running the command "ls /etc" and outputing to the console.
popen(3) - Linux man page
The popen() function opens a process by creating a pipe, forking, and invoking the shell. Since a pipe is by definition unidirectional, the type argument may specify only reading or writing, not both; the resulting stream is correspondingly read-only or write-only.
Advanced Bash-Scripting Guide: I/O Redirection
C programming - capturing information sent to stdout
藍森林-自由軟件 關於open()
沒有留言:
張貼留言