home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / misc / 3008 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  1.2 KB

  1. Path: sparky!uunet!murphy!dwrsun4!perl
  2. From: perl@dwrsun4.UUCP (Robert Perlberg)
  3. Newsgroups: comp.unix.misc
  4. Subject: Re: How to find the size of space being occupied in 1/4" cartridge tape?
  5. Message-ID: <2766@perl-sun.dwrsun4.UUCP>
  6. Date: 17 Jul 92 19:26:56 GMT
  7. References: <1992Jul10.065509.1197@mdd.comm.mot.com>
  8. Organization: Dean Witter Reynolds Inc., New York
  9. Lines: 24
  10.  
  11. In article <1992Jul10.065509.1197@mdd.comm.mot.com>, to@mdd.comm.mot.com (Ricky To) writes:
  12. > I am trying to write a C program to find the size of space currently
  13. > being occupied by files in a 1/4" cartridge tape. ...
  14.  
  15. > Unfortunately, this code does not work.  The reason is that fscanf()
  16. > is not able to catch the error message.  Could anybody suggest any
  17. > workarounds for this problem, or even another technique to find the
  18. > size of the space?  Thanks in advance.
  19.  
  20. Well, to catch the error messages use the "2>&1" shell operator, thus:
  21.  
  22.     fd = popen ("tar tvf /dev/nrst0 2>&1", "r");
  23.  
  24. This merges stderr with stdout.
  25.  
  26. Unless I'm missing something, couldn't you do this more easily with
  27. something like this?:
  28.  
  29.     dd if=/dev/nrst0 bs=126b | wc -c
  30.  
  31. Robert Perlberg
  32. Dean Witter Reynolds Inc., New York
  33. {murphy | philabs}!dwrsun4!perl
  34.     -- "I am not a language ... I am a free man!"
  35.