home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 5002 < prev    next >
Encoding:
Text File  |  1992-07-28  |  1.9 KB  |  57 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!gatech!europa.asd.contel.com!darwin.sura.net!convex!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: stat.pl query
  5. Message-ID: <1992Jul28.173304.27422@news.eng.convex.com>
  6. Originator: tchrist@pixel.convex.com
  7. Keywords: PERL
  8. Sender: usenet@news.eng.convex.com (news access account)
  9. Nntp-Posting-Host: pixel.convex.com
  10. Reply-To: tchrist@convex.COM (Tom Christiansen)
  11. Organization: CONVEX Realtime Development, Colorado Springs, CO
  12. References: <1992Jul28.171317.22804@rdg.dec.com>
  13. Date: Tue, 28 Jul 1992 17:33:04 GMT
  14. X-Disclaimer: This message was written by a user at CONVEX Computer
  15.               Corp. The opinions expressed are those of the user and
  16.               not necessarily those of CONVEX.
  17. Lines: 38
  18.  
  19. From the keyboard of stuart@ds3100.new.dec.com (Stuart Broderick):
  20. :Probably a stupid question, but....
  21. :
  22. :The following script is using stat.pl to determine the mode of a file
  23. :using stat.pl. 
  24. :
  25. :#! /usr/local/bin/perl
  26. :require 'stat.pl';
  27. :do Stat('./test');
  28. :print $st_mode,"\t",$st_uid,"\t",$st_gid,"\n";
  29. :
  30. :When this runs, I get 
  31. :
  32. :st_mode st_uid  st_gid
  33. :33224   1103    100
  34. :
  35. :When I do a "ls -lag ./test",  I get
  36. :
  37. :-rwx--x---  1 stuart   espo       286720 Jul 28 17:56 ./test
  38. :
  39. :The username and group are correct (st_uid, st_gid), but what does
  40. :st_mode relate to ? 
  41. :I expected it to give 0710. 
  42. :
  43. :Can anyone tell me what I've done wrong ? I'm looking for a numeric
  44. :representation of 
  45. :the permissions field.
  46.  
  47. You should check the stat(2) man page.  mode contains both inode type and
  48. permissions.  usually you &= 07777 to get just the permissions, which you
  49. then may want to print out with a %04o printf mask.
  50.  
  51. --tom
  52. -- 
  53.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  54. echo $package has manual pages available in source form.
  55. echo "However, you don't have nroff, so they're probably useless to you."
  56.     --Larry Wall in Configure from the perl distribution
  57.