![]() |
|
#1
|
|||
|
|||
reading the result of an external commandsounds simple, but can i get it?!!
i'm writing a small program, for which part of it's job will be to run other programs. these have text responses (return value is no good), but i cannot figure out how to read them!! e.g. external_program=check_whatever return_text = system(external_program) check_whatever dumps it's text on stdout, which ofcourse is to the screen. how can i read that response? the above is what i want to achieve in laymans terms, but i cannot figure out how to do it. i dont want to use a tempfile (as my program can be potentially writing an burning 20 per second anyway because of the socket it is reading - dont ask lol, it's my bad coding )i'm sure theres just one command to do it, but i'll be b&**^% if i can work it out - anyone know? B |
|
#2
|
|||
|
|||
|
forgot to say
1/) debian linux 2/) C, not C++ (i think, how you tell) 3/) first post - um - hi!! B p.s. C baffles me, but shell script no problem, however it's inefficient, doesnt use message queues (which i neeed for IPC, however i have a freebee from the net for that |
|
#3
|
||||
|
||||
|
Quote:
Quote:
Alternative is when you output the information to the screen you also output it to a file which the calling program then reads. In most cases the screen is not available to you, it hardware, so it's protected from direct access. And even if it wasn't, where would the text be? Top? Bottom? Where was the cursor when the program started? I'd recommend the first as the easiest option, the second if you're outputting dynamic text (names, addresses) that will cahnge with each execution. __________________
Age is unimportant -- except in cheese |
|
#4
|
||||
|
||||
|
Hello Mr B. Welcome to GIDForums™.
I have actually written a little tutorial that may (or may not) help. Using a inter process pipe you can connect one end to the stdout of a program and the other end to the stdin of a program. The calling mechanism used has to be the fork & spawn calls so that the pipe can be set up across both programs. Take a look here. It is written in C, esp. for Linux. Not sure if that is exactly what you need, but you may be able to adapt it to work for you. Good luck! __________________
The best damn Sports Blog period. |
Recent GIDBlog
Developing GUIs with wxPython (Part 3) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| Outputting function result to an array | Shufty | C Programming Language | 4 | 07-May-2004 10:45 |
| reading a char* into struct data | spike666 | C Programming Language | 7 | 19-Apr-2004 12:06 |
| including external libraries | kenbrilliant | C++ Forum | 1 | 15-Dec-2003 13:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The