Experts: Help!!! SYSTEM command and grabbing STDOUT 
Author Message
 Experts: Help!!! SYSTEM command and grabbing STDOUT

I need to instead of doing a system("command > file"); and then reading
the file... I need to do something faster: if the command writes to
STDOUT, how can my program automatically open the STDOUT as a stream so
I can get the command output right away and not have to wait for I/O
etc...
Thank you!
(I am trying to do a PING and get the results of it as soon as possible)


Mon, 26 Nov 2001 03:00:00 GMT  
 Experts: Help!!! SYSTEM command and grabbing STDOUT

Quote:

> I need to instead of doing a system("command > file"); and then reading
> the file... I need to do something faster: if the command writes to
> STDOUT, how can my program automatically open the STDOUT as a stream so
> I can get the command output right away and not have to wait for I/O
> etc...

ANSI-C provides no solution for what you want. However, if you are
programming under a POSIX.1 system, you can try for the popen() call. On
POSIX, it is typically a wrapper for pipe,dup,fork, and exec. It returns a
standard I/O stream for you to read from.

Check the documentation provided with your compiler library for popen().

L8r,
Mark G.
 - http://www.emi.net/~markg



Mon, 26 Nov 2001 03:00:00 GMT  
 Experts: Help!!! SYSTEM command and grabbing STDOUT
You can't. Why not write your own ping routine? You would learn more.

--

Paul Lutus
www.arachnoid.com

Quote:

>I need to instead of doing a system("command > file"); and then reading
>the file... I need to do something faster: if the command writes to
>STDOUT, how can my program automatically open the STDOUT as a stream so
>I can get the command output right away and not have to wait for I/O
>etc...
>Thank you!
>(I am trying to do a PING and get the results of it as soon as possible)



Mon, 26 Nov 2001 03:00:00 GMT  
 Experts: Help!!! SYSTEM command and grabbing STDOUT

Quote:

> I need to instead of doing a system("command > file"); and then reading
> the file... I need to do something faster: if the command writes to
> STDOUT, how can my program automatically open the STDOUT as a stream so
> I can get the command output right away and not have to wait for I/O
> etc...


There is no support for what you want to do in ANSI-C. But your operating
system or some OS specific compiler extensions might contain the solution
for your problem. Please ask this question in a newsgroup where the
programming experts for your system type can be found. For instance for a
Unix solution your would ask in:

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Tue, 27 Nov 2001 03:00:00 GMT  
 Experts: Help!!! SYSTEM command and grabbing STDOUT

Quote:

> I need to instead of doing a system("command > file"); and then reading
> the file... I need to do something faster: if the command writes to
> STDOUT, how can my program automatically open the STDOUT as a stream so

Did you try popen()?

Quote:
> I can get the command output right away and not have to wait for I/O
> etc...
> Thank you!
> (I am trying to do a PING and get the results of it as soon as possible)

--
Vladimir Olchevskii


Tue, 27 Nov 2001 03:00:00 GMT  
 Experts: Help!!! SYSTEM command and grabbing STDOUT
Groovy hepcat Vladimir Olchevskii was jivin' on 11 Jun 1999 09:04:48
+0200 in comp.lang.c.
Re: Experts: Help!!! SYSTEM command and grabbing STDOUT's a cool
scene! Dig it!

Quote:
>Did you try popen()?

  There's no such function in the ANSI/ISO/IEC standard C library.
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
    http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============



Sun, 02 Dec 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help trapping stdout from Unix system() call

2. Inexplicable System call failure - HELP - expert needed

3. Inexplicable system call failure! HELP-Expert Needed

4. Trapping Menu ID (command) and Grabbing Menu label in Doc/View

5. Grabbing the system time?

6. system() command help needed

7. Help, (system) function, command line args

8. HELP: Passing C variable to UNIX system command

9. HELP: Passing C variable to UNIX system command

10. Help, system command mysteriously disappeared when maximized

11. getting stdout from a CreateProcess command call

12. stdout for system() platform independent

 

 
Powered by phpBB® Forum Software