home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / msdos / programm / 12454 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.8 KB

  1. Path: sparky!uunet!olivea!sgigate!sgi!twilight!zola!glass.esd.sgi.com!donl
  2. From: donl@glass.esd.sgi.com (donl mathis)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: tee for DOS?
  5. Message-ID: <vbdgujg@zola.esd.sgi.com>
  6. Date: 26 Jan 93 02:45:17 GMT
  7. References: <1993Jan22.184439.27754@magnus.acs.ohio-state.edu> <1juom5INNgak@darkstar.UCSC.EDU>
  8. Sender: news@zola.esd.sgi.com (Net News)
  9. Reply-To: donl@glass.esd.sgi.com (donl mathis)
  10. Organization: Silicon Graphics, Inc.
  11. Lines: 40
  12.  
  13.  
  14. In article <1juom5INNgak@darkstar.UCSC.EDU>, spencer@cats.ucsc.edu
  15. (Michael Spencer) writes:
  16. |> 
  17. |> 
  18. |> esova@magnus.acs.ohio-state.edu (Edward R Sova) writes:
  19. |> 
  20. |> >Where can I get the Unix tee command for DOS?  You can split
  21. redirection and
  22. |> >piping.  like maybe foo | tee > prn >logfile.  Well I'm not sure of the 
  23. |> >syntax, and I don't care right now, but I think you see what I want.  Where
  24. |> >is it?  Thanx
  25. |> 
  26. |> Roll your own. Code goes something like this:
  27. |> 
  28. |> while (! feof(stdin))  {
  29. |>     fgets (str, 255, stdin);
  30. |>     fputs (str, stderr);        // send to screen
  31. |>     fputs (str, stdout);        // send whereever directed
  32. |>     }
  33. |> fflush (stderr);
  34. |> fflush (stdout);
  35. |> close (dup(fileno(stdout)));        // ensure flushing on stdout
  36.  
  37. Note that these are not the "tee" semantics that we all know and love.
  38. The command line is
  39.  
  40.     tee [ -i ] [ -a ] [ file ] ...
  41.  
  42. where -i is "ignore interrupts", which we don't care about, "-a" is to
  43. append rather than overwrite existing files, and "file" and following
  44. are the names of zero or more files into which a copy of stdin is
  45. written, along with being sent to stdout.
  46.  
  47. So, technically, you'd want to open a vector of zero or more files, and
  48. write each line into each of them as well as onto stdout.  This is a
  49. few more lines of code, but still not exactly a nightmare.
  50.  
  51. - donl mathis at Silicon Graphics Computer Systems, Mountain View, CA
  52. donl@sgi.com
  53.