<?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 permissions? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887311#M102191</link>
    <description>Hi Kris:&lt;BR /&gt;&lt;BR /&gt;No argument that perl is shorter/faster here, but here's another shell solution I offered sometime ago when this question was asked:&lt;BR /&gt;&lt;BR /&gt;The script returns the octal numeric mode of the file passed to it. The script handles the setuid, setgid and sticky bits in addition to the standard permissions: &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;# &lt;BR /&gt;typeset -i PERMFCT=0 #...permission mode factor &lt;BR /&gt;typeset -i MISCFCT=0 #...miscellaneous mode factor &lt;BR /&gt;typeset -i BITSNBR=2 #...bit number (1-relative) &lt;BR /&gt;typeset -i BITSVAL=0 #...simple bit value &lt;BR /&gt;typeset -i OCTMODE=0 #...final, octal numeric mode &lt;BR /&gt;# &lt;BR /&gt;[ "$#" != 1 ] &amp;amp;&amp;amp; { echo "Usage: $0 file"; exit 1 ; } &lt;BR /&gt;# &lt;BR /&gt;SMODE=`ls -l $1|awk '{print $1}` &lt;BR /&gt;# &lt;BR /&gt;while (( BITSNBR &amp;lt;= 10 )) &lt;BR /&gt;do &lt;BR /&gt;case `expr \( $BITSNBR - 2 \) / 3` in #...establish weighted values... &lt;BR /&gt;0 )&lt;BR /&gt;PERMFCT=100 &lt;BR /&gt;MISCFCT=4000 &lt;BR /&gt;;; &lt;BR /&gt;1 )&lt;BR /&gt;PERMFCT=10 &lt;BR /&gt;MISCFCT=2000 &lt;BR /&gt;;; &lt;BR /&gt;2 )&lt;BR /&gt;PERMFCT=1 &lt;BR /&gt;MISCFCT=1000 &lt;BR /&gt;;; &lt;BR /&gt;esac &lt;BR /&gt;# &lt;BR /&gt;case `expr substr $SMODE $BITSNBR 1` in &lt;BR /&gt;r )&lt;BR /&gt;BITSVAL=4 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;w )&lt;BR /&gt;BITSVAL=2 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;x )&lt;BR /&gt;BITSVAL=1 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;s|t ) &lt;BR /&gt;BITSVAL=1 &lt;BR /&gt;;; &lt;BR /&gt;S|T ) &lt;BR /&gt;BITSVAL=0 &lt;BR /&gt;;; &lt;BR /&gt;* )&lt;BR /&gt;BITSVAL=0 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;esac &lt;BR /&gt;# &lt;BR /&gt;OCTMODE=`expr $PERMFCT \* $BITSVAL + $MISCFCT + $OCTMODE` &lt;BR /&gt;# &lt;BR /&gt;let BITSNBR=$BITSNBR+1 &lt;BR /&gt;done &lt;BR /&gt;# &lt;BR /&gt;echo "mode = $OCTMODE" &lt;BR /&gt;exit 0 &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 22 Jan 2003 12:51:06 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2003-01-22T12:51:06Z</dc:date>
    <item>
      <title>Numeric file permissions?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887308#M102188</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Is there an easy way to display the permissions of a file in numeric format like "775"? &lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Kris&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jan 2003 23:40:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887308#M102188</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2003-01-21T23:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file permissions?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887309#M102189</link>
      <description>Hi Kris:&lt;BR /&gt;&lt;BR /&gt;Probably about the easiest method is to use Perl's stat() function.&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;fmode.pl myfile1 myfile2 &lt;BR /&gt;to output&lt;BR /&gt;myfile1 775&lt;BR /&gt;myfile2 600&lt;BR /&gt;&lt;BR /&gt;I already had this one written.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jan 2003 23:43:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887309#M102189</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-01-21T23:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file permissions?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887310#M102190</link>
      <description>Hi Kris,&lt;BR /&gt;&lt;BR /&gt;I tried to write a script in shell just for sake of it and ofcourse for my fun. I made it bit eloborate so that I wouldn't get confused myself while writing it. This lists the permissions in four digit format. For ex., 4555 or 0555 so that you would know if the file has suid/sgid/sticky bits. &lt;BR /&gt;&lt;BR /&gt;Call it get_perms.ksh and run it with &lt;BR /&gt;&lt;BR /&gt;---start---&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh                                            &lt;BR /&gt;if [ $# -ne 1 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Usage: $0 file"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;                                                          &lt;BR /&gt;PERM=$(ll $1|sed 's/-/0/g'| awk '{print $1}')             &lt;BR /&gt;                                &lt;BR /&gt;A=0                                                                                          &lt;BR /&gt;                                                          &lt;BR /&gt;B=$(echo $PERM|cut -c 4)                                  &lt;BR /&gt;                                                          &lt;BR /&gt;if [[ "$B" = "s" || "$B" = "S" ]]                         &lt;BR /&gt;then                                                      &lt;BR /&gt;   (( A = $A + 4 ))                                       &lt;BR /&gt;fi                                                        &lt;BR /&gt;                                                          &lt;BR /&gt;C=$(echo $PERM|cut -c 7)                                  &lt;BR /&gt;                                                          &lt;BR /&gt;if [[ "$C" = "s" || "$C" = "S" ]]                         &lt;BR /&gt;then                                                      &lt;BR /&gt;   (( A = $A + 2 ))                                       &lt;BR /&gt;fi                                                        &lt;BR /&gt;D=$(echo $PERM|cut -c 10)                                 &lt;BR /&gt;                                                          &lt;BR /&gt;if [[ "$C" = "t" || "$C" = "T" ]]                         &lt;BR /&gt;then                                                                            &lt;BR /&gt;   (( A = $A + 1 ))                                                             &lt;BR /&gt;fi                                                                              &lt;BR /&gt;                                                                                &lt;BR /&gt;PERM=$(echo $PERM|sed -e 's/r/4/g' -e 's/w/2/g' -e 's/x/1/g' -e 's/s/1/g' -e 's/&lt;BR /&gt;t/1/g' -e 's/S/0/g' -e 's/T/0/g')                                               &lt;BR /&gt;                                                                                &lt;BR /&gt;                                                                                &lt;BR /&gt;                                                                                &lt;BR /&gt;printf "$A"                                                                     &lt;BR /&gt;                                                                                &lt;BR /&gt;printit()                                                                       &lt;BR /&gt;{                                                                               &lt;BR /&gt;c=0                                                                             &lt;BR /&gt;K=$1                                                                            &lt;BR /&gt;for i in $K                                                                     &lt;BR /&gt;do                                                                              &lt;BR /&gt;VAL=$(echo $PERM|cut -c $i)                                                     &lt;BR /&gt;((c = $c + $VAL ))                                                              &lt;BR /&gt;done                                                                            &lt;BR /&gt;printf "$c"                   &lt;BR /&gt;}                             &lt;BR /&gt;                              &lt;BR /&gt;printit "2 3 4"               &lt;BR /&gt;printit "5 6 7"               &lt;BR /&gt;printit "8 9 10 "             &lt;BR /&gt;                              &lt;BR /&gt;printf "         $1\n"        &lt;BR /&gt;                                                                                                         &lt;BR /&gt;---End--&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;PS: Becareful while cutting pasting the sed statement. It should be in one line.</description>
      <pubDate>Wed, 22 Jan 2003 00:46:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887310#M102190</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-01-22T00:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file permissions?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887311#M102191</link>
      <description>Hi Kris:&lt;BR /&gt;&lt;BR /&gt;No argument that perl is shorter/faster here, but here's another shell solution I offered sometime ago when this question was asked:&lt;BR /&gt;&lt;BR /&gt;The script returns the octal numeric mode of the file passed to it. The script handles the setuid, setgid and sticky bits in addition to the standard permissions: &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;# &lt;BR /&gt;typeset -i PERMFCT=0 #...permission mode factor &lt;BR /&gt;typeset -i MISCFCT=0 #...miscellaneous mode factor &lt;BR /&gt;typeset -i BITSNBR=2 #...bit number (1-relative) &lt;BR /&gt;typeset -i BITSVAL=0 #...simple bit value &lt;BR /&gt;typeset -i OCTMODE=0 #...final, octal numeric mode &lt;BR /&gt;# &lt;BR /&gt;[ "$#" != 1 ] &amp;amp;&amp;amp; { echo "Usage: $0 file"; exit 1 ; } &lt;BR /&gt;# &lt;BR /&gt;SMODE=`ls -l $1|awk '{print $1}` &lt;BR /&gt;# &lt;BR /&gt;while (( BITSNBR &amp;lt;= 10 )) &lt;BR /&gt;do &lt;BR /&gt;case `expr \( $BITSNBR - 2 \) / 3` in #...establish weighted values... &lt;BR /&gt;0 )&lt;BR /&gt;PERMFCT=100 &lt;BR /&gt;MISCFCT=4000 &lt;BR /&gt;;; &lt;BR /&gt;1 )&lt;BR /&gt;PERMFCT=10 &lt;BR /&gt;MISCFCT=2000 &lt;BR /&gt;;; &lt;BR /&gt;2 )&lt;BR /&gt;PERMFCT=1 &lt;BR /&gt;MISCFCT=1000 &lt;BR /&gt;;; &lt;BR /&gt;esac &lt;BR /&gt;# &lt;BR /&gt;case `expr substr $SMODE $BITSNBR 1` in &lt;BR /&gt;r )&lt;BR /&gt;BITSVAL=4 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;w )&lt;BR /&gt;BITSVAL=2 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;x )&lt;BR /&gt;BITSVAL=1 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;s|t ) &lt;BR /&gt;BITSVAL=1 &lt;BR /&gt;;; &lt;BR /&gt;S|T ) &lt;BR /&gt;BITSVAL=0 &lt;BR /&gt;;; &lt;BR /&gt;* )&lt;BR /&gt;BITSVAL=0 &lt;BR /&gt;MISCFCT=0 &lt;BR /&gt;;; &lt;BR /&gt;esac &lt;BR /&gt;# &lt;BR /&gt;OCTMODE=`expr $PERMFCT \* $BITSVAL + $MISCFCT + $OCTMODE` &lt;BR /&gt;# &lt;BR /&gt;let BITSNBR=$BITSNBR+1 &lt;BR /&gt;done &lt;BR /&gt;# &lt;BR /&gt;echo "mode = $OCTMODE" &lt;BR /&gt;exit 0 &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 22 Jan 2003 12:51:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887311#M102191</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-01-22T12:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric file permissions?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887312#M102192</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I decided to use A. Clay's method. It was was much easier.&lt;BR /&gt;&lt;BR /&gt;Thanks to everybody,&lt;BR /&gt;Kris</description>
      <pubDate>Wed, 22 Jan 2003 17:53:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/numeric-file-permissions/m-p/2887312#M102192</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2003-01-22T17:53:03Z</dc:date>
    </item>
  </channel>
</rss>

