Store the output of a Unix cmd in a C program

July 12, 2010 at 00:04:55
Specs: Unix
Hello experts,

How can I retrieve the output from a Unix command and use it as string variable in my C program?
For example, when I issue the command 'date' in Unix I get:
Tue Jun 11 09:54:16 EEST 2009

I'd like to be able to store the above output as string in my C program.

Thanks in advance,
Goseib


See More: Store the output of a Unix cmd in a C program

Report •

#1
July 12, 2010 at 07:00:12
One way is to use pipes which means using the popen "C" library call. This article describes how to do use it:

http://www.theillien.com/Sys_Admin_...


Report •

#2
July 12, 2010 at 22:38:07
thank you nails. I will go with the popen!

Report •
Related Solutions


Ask Question