- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need help for shell script
Operating System - HP-UX
1753500
Members
3682
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО07-28-2008 08:49 PM
тАО07-28-2008 08:49 PM
need help for shell script
Dear Unix Expertise,
I need your help to write following shell script, as i am new to this area...
----------
Display the Octal value of Root Home Directory (700 / 750 / 777), User Home Directory and Application Home Directory...
For e.g. Result Should be like :
"Root Home Directory Octal Value : 700"
I want the OCTAL STATUS Output for each of these direcotries..
Pl. help me for this.
Thanks in Advance...
Regards,
Mikin
I need your help to write following shell script, as i am new to this area...
----------
Display the Octal value of Root Home Directory (700 / 750 / 777), User Home Directory and Application Home Directory...
For e.g. Result Should be like :
"Root Home Directory Octal Value : 700"
I want the OCTAL STATUS Output for each of these direcotries..
Pl. help me for this.
Thanks in Advance...
Regards,
Mikin
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2008 10:30 PM
тАО07-28-2008 10:30 PM
Re: need help for shell script
You could just use something like the following. It doesn't handle sticky or setuid or setgid bits.
#!/usr/bin/ksh
#Display the Octal value of Root Home Directory (700 / 750 / 777),
#User Home Directory and Application Home Directory...
decode_3() {
octal=$1
r=${octal%??}
octal=${octal#?} # remove r
w=${octal%?}
x=${octal#?} # remove w
# echo "r:$r w:$w x:$x"
typeset -i total=0
if [ "$r" = "r" ]; then
(( total += 4 ))
fi
if [ "$w" = "w" ]; then
(( total += 2 ))
fi
if [ "$x" = "x" ]; then
(( total += 1 ))
fi
echo $total
}
decode_permission() {
perm=${1#?} # remove first
u_perm=${perm%??????}
perm=${perm#???} # remove user
g_perm=${perm%???}
o_perm=${perm#???} # remove group
# echo "u:$u_perm g:$g_perm o:$o_perm $2"
echo "$(decode_3 $u_perm)$(decode_3 $g_perm)$(decode_3 $o_perm) $2"
}
for file in ~root ~ $*; do
decode_permission $(ll -d $file | awk '{print $1, $9}')
done
#!/usr/bin/ksh
#Display the Octal value of Root Home Directory (700 / 750 / 777),
#User Home Directory and Application Home Directory...
decode_3() {
octal=$1
r=${octal%??}
octal=${octal#?} # remove r
w=${octal%?}
x=${octal#?} # remove w
# echo "r:$r w:$w x:$x"
typeset -i total=0
if [ "$r" = "r" ]; then
(( total += 4 ))
fi
if [ "$w" = "w" ]; then
(( total += 2 ))
fi
if [ "$x" = "x" ]; then
(( total += 1 ))
fi
echo $total
}
decode_permission() {
perm=${1#?} # remove first
u_perm=${perm%??????}
perm=${perm#???} # remove user
g_perm=${perm%???}
o_perm=${perm#???} # remove group
# echo "u:$u_perm g:$g_perm o:$o_perm $2"
echo "$(decode_3 $u_perm)$(decode_3 $g_perm)$(decode_3 $o_perm) $2"
}
for file in ~root ~ $*; do
decode_permission $(ll -d $file | awk '{print $1, $9}')
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2008 04:17 AM
тАО07-29-2008 04:17 AM
Re: need help for shell script
Hi:
Use Perl;
# perl -le 'printf("%04o %-s\n",((stat($_))[2])&07777,$_) for @ARGV' file_or_directory
That is, pass one or more arguments for 'file_or_directory'. For example:
# perl -le 'printf("%04o %-s\n",((stat($_))[2])&07777,$_) for @ARGV' /var/tmp /home /etc/hosts
1777 /var/tmp
0755 /home
0644 /etc/hosts
Regards!
...JRF...
Use Perl;
# perl -le 'printf("%04o %-s\n",((stat($_))[2])&07777,$_) for @ARGV' file_or_directory
That is, pass one or more arguments for 'file_or_directory'. For example:
# perl -le 'printf("%04o %-s\n",((stat($_))[2])&07777,$_) for @ARGV' /var/tmp /home /etc/hosts
1777 /var/tmp
0755 /home
0644 /etc/hosts
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2008 04:22 AM
тАО07-29-2008 04:22 AM
Re: need help for shell script
Courtesy of Jack Mahaffey, here's "getchmod" (attached).
Pete
Pete
Pete
Pete
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP