Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting the output of an external program

Posted on 2007-04-04
2
Medium Priority
?
204 Views
Last Modified: 2012-05-05
Hi experts,

I need a program that does the following in linux:
Run an external program eg. system("ls -l") and then parse the output of the external program.

One way is to redirect the output of external program to a file and then my program parse the file.
However, I need to do this many times in the program and need it to be fast.

Is there anyway in C I can get the output of the external program straight into an array in my program?
Cause I don't want to first write to a file and then later open the file and parse it (too slow).

Thanks.



0
Comment
Question by:help-me
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 18855858
FILE *F= popen("ls -l", "r");
fread(buffer,1,sizeof(buffer),F);
0
 
LVL 1

Author Comment

by:help-me
ID: 18855949
tested..... its works!!  cool!!

Thanks a lot!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question