how to read bash shell command output in c program. In this tutorial we will learn about Linux popen system call. popen system call can be used to read bash shell command output. The popen()  and pclose() system call is easier to use.

From Linux manual:

Let us write a simplest shell command.

 it will print Hello WikiStack on terminal output.

Now we will write a simple c program using popen() system call which will execute our shell command. popen() function returns a stream. we will read shell command output by using this stream.

how to read bash shell command output in c program

Note: Do comment if there is more improved way.

Ref:

http://stackoverflow.com/questions/9434207/reading-from-file-using-fgets




Related Contents to follow