Programming REXEC() with input and output streams 
Author Message
 Programming REXEC() with input and output streams

Hi everybody,

I would like to use the rexec( ... ) function to run the wc utility on a remote

machine, with an input sent from the local machine, and to get the output back
on the local machine (don't ask why, it is just an example).

The code I wrote for this follows :

     char ch;
     struct servent *servent;
     FILE *fpo,*fpi;
     int sd;

     servent = getservbyname("exec", "tcp");
     sd = rexec(host, servent->s_port, user, passwd, "wc", 0);
     fpi = fdopen(sd, "w");
     fpo = fdopen(sd, "r");

     while ((ch=fgetc(stdin)) !=EOF) fputc(ch,fpi);
     fflush(fpi);

     printf("input over\n");

     while ((ch=fgetc(fpo)) !=EOF) fputc(ch,stdout);
     fflush(fpo);

It lets me enter a text to which I put an end with a nice little ^D,
displays "input over" and waits just as if the remote wc process was still
waiting for data.

In fact, it seems to me that wc does not 'see' the remote ^D as it would see
a local one. So, the question is:

'How do I tell wc that it doesn't have anything else to expect from its input
stream' ???

  Any hint about this problem is very welcome.

  Thanks in advance, Ben.

--
+----------------------+----------------------------------------+-------------+

| G.E.M.H.             |                                        |             |
| B.P. 540             | Phone : (33) 35 53 69 36               |             |
| 76058 LE HAVRE CEDEX | Fax   : (33) 35 19 57 15               |             |
+----------------------+----------------------------------------+-------------+



Wed, 10 Dec 1997 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Unable to sync input and output streams

2. Can't sync input and output streams...

3. Difficulty with input/output streams

4. input, output, input/output parameters?????

5. Redirecting input and output of a program

6. output of one program as input for another

7. Output to printer input to my program.

8. C++ program input/output.

9. Input/output in C function called by Fortran Program

10. Differences between C programs output and win outputs

11. Outputting DOS program output to a MFC window

12. How to clear input stream in ANSI C?

 

 
Powered by phpBB® Forum Software