- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Octal file permissions?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:31 AM
08-13-2002 08:31 AM
Is there an easy way to display a file's permission as separate octal digits? My ideal display would be:
filename1 6 4 0
filename2 7 1 1
for
filename1 rw-r-----
filename2 rwx--x--x
Thanks in advance,
Ryan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:34 AM
08-13-2002 08:34 AM
Re: Octal file permissions?
See here:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xe3288ffa98a2d5118ff10090279cd0f9,00.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:37 AM
08-13-2002 08:37 AM
Re: Octal file permissions?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x006c1cc6003bd6118fff0090279cd0f9,00.html
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:37 AM
08-13-2002 08:37 AM
SolutionThis should be close:
#!/usr/bin/perl -w
use strict;
my $i = 0;
while ($i <= $#ARGV)
{
my $mode = (stat($ARGV[$i]))[2];
printf("%s\t%o\t%o\t%o\n",$ARGV[$i],
($mode & 0700) >> 6,
($mode & 070) >> 3,
$mode & 07);
++$i;
}
I'm doing this 'on the fly' so there might be a missing ')' but this should be very close.
You might also want to add a test (-e) to make sure the file exists before doing the stat.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:39 AM
08-13-2002 08:39 AM
Re: Octal file permissions?
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 08:40 AM
08-13-2002 08:40 AM
Re: Octal file permissions?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x3c76107d277ad611abdb0090277a778c,00.html
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 09:01 AM
08-13-2002 09:01 AM
Re: Octal file permissions?
Thanks, Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 09:07 AM
08-13-2002 09:07 AM
Re: Octal file permissions?
Normally I don't spoonfeed you but here you go:
#!/usr/bin/perl -w
use strict;
my $i = 0;
my $cc = 0;
while ($i <= $#ARGV && $cc == 0)
{
if (-e $ARGV[$i])
{
my $mode = (stat($ARGV[$i]))[2];
printf("%s\t%o\t%o\t%o\n",$ARGV[$i],
($mode & 0700) >> 6,
($mode & 070) >> 3,
$mode & 07);
}
else
{
printf STDERR ("File '%s' not found.\n",
$ARGV[$i]);
$cc = 2;
}
++$i;
}
exit($cc);
-----------------------------------
That should do it (if there are no typo's) .
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 09:17 AM
08-13-2002 09:17 AM
Re: Octal file permissions?
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 09:38 AM
08-13-2002 09:38 AM
Re: Octal file permissions?
l1:/stand 113 > perl -le 'print"$_\t@{[split//,sprintf q(%03o),(stat)[2]&511]}"for@ARGV' *
bootconf 6 4 4
build 7 5 5
dlkm 7 5 5
dlkm.vmunix.prev 7 5 5
ioconfig 6 4 4
kernrel 4 4 4
lost+found 7 5 5
rootconf 6 0 0
system 4 4 4
system.d 7 5 5
system.prev 6 4 4
vmunix 7 5 5
vmunix.prev 7 5 5
l1:/stand 114 >
Beat that Clay!