<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Numeric file modes in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741436#M943941</link>
    <description>Hello again,&lt;BR /&gt;&lt;BR /&gt;I need help with a small change. I would really like this to print separate digits for "owner","group", and "other". If I do this command "perms user1.dat", the script displays "user1.dat 664". I would like it to display "user1.dat 6 6 4". I know I could do this with cut  but I would rather do this directly in the perms perl program because I need to process thousands of files. This is probably easy for a perl programmer but  I can't seem to get it to work. Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks, Kris</description>
    <pubDate>Tue, 11 Jun 2002 21:05:58 GMT</pubDate>
    <dc:creator>Kris Spander</dc:creator>
    <dc:date>2002-06-11T21:05:58Z</dc:date>
    <item>
      <title>Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741430#M943935</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;A friend suggested that I ask you guys. Is there an easy way to get a file's permission in numeric form rather than rw-rw-rw-?&lt;BR /&gt;I am trying to use a case inside a script and the symbolic forms are such a pain. Anybody know an easy method?&lt;BR /&gt;&lt;BR /&gt;Thanks, Kris&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 18:25:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741430#M943935</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2002-06-10T18:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741431#M943936</link>
      <description>Hi Kris:&lt;BR /&gt;&lt;BR /&gt;Can you say 'Perl'?&lt;BR /&gt;&lt;BR /&gt;Try this 60-second quickie:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;my $i = 0;&lt;BR /&gt;while ($i &amp;lt;= $#ARGV)&lt;BR /&gt;  {&lt;BR /&gt;    my $mode = (stat($ARGV[$i]))[2];&lt;BR /&gt;    printf("%s\t%03o\n",$ARGV[$i],$mode &amp;amp; 0777);&lt;BR /&gt;    ++$i;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;That should do it. We are taking a slice (the 3rd element) from the stat function. &lt;BR /&gt;&lt;BR /&gt;For each argument on the command line, you get a filename and the octal permissions.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 18:30:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741431#M943936</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-10T18:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741432#M943937</link>
      <description>Using perl-&lt;BR /&gt;&lt;BR /&gt;perl -e '$file=&lt;STDIN&gt; ; chomp $file; @x=stat $file ; printf "%4o\n",$x[2]'&lt;BR /&gt;&lt;BR /&gt;Run this and enter in the filename and it will display in octal the permissions.&lt;BR /&gt;&lt;BR /&gt;I wrote this so it could be used as a filter program.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;/STDIN&gt;</description>
      <pubDate>Mon, 10 Jun 2002 18:33:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741432#M943937</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-10T18:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741433#M943938</link>
      <description>#!/usr/bin/perl &lt;BR /&gt;use File::Find; &lt;BR /&gt;{ &lt;BR /&gt;$filename = $ARGV[0]; &lt;BR /&gt;finddepth(\&amp;amp;wanted,"$filename"); &lt;BR /&gt;} &lt;BR /&gt;sub wanted { &lt;BR /&gt;my ($dev,$ino,$mode,$nlink,$uid,$gid); &lt;BR /&gt;if ((($f_dev,$f_ino,$f_mode,$f_nlink,$f_uid,$f_gid,$f_rdev,$f_size,$f_at &lt;BR /&gt;ime,$f_mtime,$f_ctime,$f_blksize,$f_blocks) = lstat($_))) { &lt;BR /&gt;$f_filetype = substr(sprintf("%6.6o",$f_mode),0,2); &lt;BR /&gt;$f_filemode = substr(sprintf("%6.6o",$f_mode),2,4); &lt;BR /&gt;printf("%d:%s:%s:%d:%d:%d:%d:%d:%d:%d:%d:%d:%s\n",$f_ino,$f_filetype, &lt;BR /&gt;$f_filemode,$f_uid,$f_gid,$f_rdev,$f_size,$f_atime,$f_mtime,$f_ctime,$f_blksize, &lt;BR /&gt;$f_blocks,$File::Find::name); &lt;BR /&gt;} &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;from &lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xcf7650011d20d6118ff40090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xcf7650011d20d6118ff40090279cd0f9,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;+mode +wanted&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 10 Jun 2002 18:35:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741433#M943938</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-06-10T18:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741434#M943939</link>
      <description>That was quick. I got 3 answers in about 10 minutes!!&lt;BR /&gt;&lt;BR /&gt;I used Clay's answer because it displayed just what I needed. Rodney's solution displays 6 digits and I only wanted the last 3 digits. Harry's was more than I needed. &lt;BR /&gt;&lt;BR /&gt;Thanks very much, Kris&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 19:04:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741434#M943939</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2002-06-10T19:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741435#M943940</link>
      <description>Show how grateful you are by assigning points!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;Marty</description>
      <pubDate>Mon, 10 Jun 2002 19:25:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741435#M943940</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-06-10T19:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741436#M943941</link>
      <description>Hello again,&lt;BR /&gt;&lt;BR /&gt;I need help with a small change. I would really like this to print separate digits for "owner","group", and "other". If I do this command "perms user1.dat", the script displays "user1.dat 664". I would like it to display "user1.dat 6 6 4". I know I could do this with cut  but I would rather do this directly in the perms perl program because I need to process thousands of files. This is probably easy for a perl programmer but  I can't seem to get it to work. Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks, Kris</description>
      <pubDate>Tue, 11 Jun 2002 21:05:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741436#M943941</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2002-06-11T21:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741437#M943942</link>
      <description>Hi Kris:&lt;BR /&gt;&lt;BR /&gt;I assume that you are probably doing something like this in the shell in some sort of loop:&lt;BR /&gt;&lt;BR /&gt;echo "${FNAME}" | perms.pl read FILENAME OWNER GROUP OTHER&lt;BR /&gt;&lt;BR /&gt;You would like for me to make life easier for you. Well, it is simple:&lt;BR /&gt;&lt;BR /&gt;Change:&lt;BR /&gt;printf("%s\t%03o\n",$ARGV[$i],$mode &amp;amp; 0777); &lt;BR /&gt;To:&lt;BR /&gt;printf("%s\t%o\t%o\t%o\n",&lt;BR /&gt;       $ARGV[$i],($mode &amp;amp; 0700) &amp;gt;&amp;gt; 6,&lt;BR /&gt;       ($mode &amp;amp; 070) &amp;gt;&amp;gt; 3,($mode &amp;amp; 07)); &lt;BR /&gt;&lt;BR /&gt;The &amp;gt;&amp;gt; 6 bit-shifts the operand 6 bits (2 octal digits) to the right. I could have divided by 0100 but the bit-shift is more elegant, don't you think?&lt;BR /&gt;&lt;BR /&gt;If I haven't made a typo, that should fix you. I left &lt;TABS&gt; as separators but you could replace them with spaces if you like. &lt;BR /&gt;&lt;BR /&gt;P.S. O'reilly has some excellent Perl books. Look for the ones with camels on the cover.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/TABS&gt;</description>
      <pubDate>Tue, 11 Jun 2002 21:15:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741437#M943942</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-11T21:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file modes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741438#M943943</link>
      <description>change Clay's&lt;BR /&gt;&lt;BR /&gt;printf("%s\t%03o\n",$ARGV[$i],$mode &amp;amp; 0777); &lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;@x=split(//,sprintf("%03",$mode &amp;amp; 0777));&lt;BR /&gt;printf "%s\t%s\n",$ARGV[$i],join(" ",@x);&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Jun 2002 21:30:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-modes/m-p/2741438#M943943</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-11T21:30:52Z</dc:date>
    </item>
  </channel>
</rss>

