Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Extracting output from system(3) call

Reply
Thread Tools

Extracting output from system(3) call

 
 
v4vijayakumar
Guest
Posts: n/a
 
      05-13-2006
is there any standard way to extract output from system(3) function?
TIA.

 
Reply With Quote
 
 
 
 
v4vijayakumar
Guest
Posts: n/a
 
      05-13-2006
if possible to use pipe(2) how could file descriptor can be derived
from file pointer, FILE *. TIA.

 
Reply With Quote
 
 
 
 
v4vijayakumar
Guest
Posts: n/a
 
      05-13-2006
am going to use

system("ls > /tmp/t");

 
Reply With Quote
 
Robert Harris
Guest
Posts: n/a
 
      05-13-2006
v4vijayakumar wrote:
> is there any standard way to extract output from system(3) function?
> TIA.
>


<OT>
In a Posix system, use popen(3) instead
</OT>

Robert
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-13-2006
"v4vijayakumar" <> writes:
> is there any standard way to extract output from system(3) function?
> TIA.


The C standard doesn't provide any way to do this, but your
implementation might. Try a system-specific newsgroup.

But first, please read <http://cfaj.freeshell.org/google/>.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
=?ISO-8859-1?Q?Martin_J=F8rgensen?=
Guest
Posts: n/a
 
      05-13-2006
Robert Harris wrote:
> v4vijayakumar wrote:
>
>>is there any standard way to extract output from system(3) function?
>>TIA.
>>

>
>
> <OT>
> In a Posix system, use popen(3) instead
> </OT>


BTW: What is Posix???


Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
 
Reply With Quote
 
SM Ryan
Guest
Posts: n/a
 
      05-13-2006
"v4vijayakumar" <> wrote:
# is there any standard way to extract output from system(3) function?

You have to save the output to a file within the command line,
and then open the file subsequently.
For example on unix, you can do something like
if (system("cat gloober/* >fripper")!=0) error(...);
FILE *fripper = fopen("fripper","r");
...
fclose(fripper);

POSIX systems also provide popen/pclose.
FILE *fripper = popen("cat gloober/*","r");
...
if (pclose(fripper)!=0) error(...);

--
SM Ryan http://www.rawbw.com/~wyrmwif/
But I do believe in this.
 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      05-13-2006

"Martin Jørgensen" <> wrote in message
news:084hj3-...
> Robert Harris wrote:
>> v4vijayakumar wrote:
>>
>>>is there any standard way to extract output from system(3) function?
>>>TIA.
>>>

>>
>>
>> <OT>
>> In a Posix system, use popen(3) instead
>> </OT>

>
> BTW: What is Posix???


http://en.wikipedia.org/wiki/POSIX

-Mike


 
Reply With Quote
 
v4vijayakumar
Guest
Posts: n/a
 
      05-15-2006
It seems that there is another way.

fclose (stdout);
stdout = fopen ("standard-output-file", "w");

system("ls");

/* process output file here */

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      05-15-2006
v4vijayakumar wrote:
> It seems that there is another way.


Another way to do what? Google is most definitely *not* Usenet, just an
interface that dupes people in to making incorrect assumptions. Read
http://clc-wiki.net/wiki/Intro_to_clc and provide context in future.

> fclose (stdout);
> stdout = fopen ("standard-output-file", "w");
>
> system("ls");
>
> /* process output file here */


I've got no idea what you think the above will do, but I doubt it will
actually do what you think. For a start, there is no guarantee that
changing stdout within a program will affect where the output of a
program invoked using system goes.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extracting values from vmstat output alfonsobaldaserra Perl Misc 8 02-20-2009 05:04 AM
parse output screen ok but cant get desired output new file! chuck amadi Python 1 06-23-2004 02:16 PM
Sony Precision Cinema Progressive Output vs Component 480p Output Otto Pylot DVD Video 1 04-18-2004 09:49 PM
Is Fuji S3000 3.2m/pixel output, or 6 m/pixel interpolated output? Peter H Digital Photography 43 12-04-2003 02:35 PM
Output / Debug window output bug? John Bentley ASP .Net 0 09-10-2003 07:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57