pipe breaking

Greg Woods woods at hao.UUCP
Thu Oct 31 06:24:34 AEST 1985


>  This fortran program accepts the uncompacted data from standard input
>  via an unformatted read statement and plots it; it exits from the
>  plotting loop when an EOF condition is detected.  At this point I
>  want the program to accept input from the keyboard; however, it 
>  continues to read from the pipe.  Do you have any advice on how I
>  can redirect the input once the EOF is reached?  Thanks for your support.

  This one is not too hard. You can catch the EOF, close unit 5, and then 
reopen it to read from the terminal. The code looks like:

      read(5,end=100) ...
c jumps to statement label 100 when EOF sensed
      ....
 100  close(unit=5)
c  close pipe
      open(unit=5,file='/dev/tty')
c  reopen unit 5 to terminal
      read(5,...
c read from terminal

--Greg
--
{ucbvax!hplabs | allegra!nbires | decvax!noao | mcvax!seismo | ihnp4!noao}
       		        !hao!woods

CSNET: woods at NCAR  ARPA: woods%ncar at CSNET-RELAY



More information about the Comp.unix.wizards mailing list