HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- user account info
Operating System - HP-UX
1826057
Members
4228
Online
109690
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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-04-2005 06:23 AM
07-04-2005 06:23 AM
Hi
I would really appreciate if someone can help me with a little scripting task I wanna do.
Basically I want to list the /etc/passwd, grep only the username for example only the "root" part of this "root:*:0:3::/:/sbin/sh". Pass each username through /usr/sbin/groups to identify and print user groups to a file. Then also pass each username through /usr/lbin/getprpw, and print out each users lockout=0000000 from the output of /usr/lbin/getprpw to same file so I can identify disabled accounts and for what reason based on the bit (1 or 0).
Thanks!!
I would really appreciate if someone can help me with a little scripting task I wanna do.
Basically I want to list the /etc/passwd, grep only the username for example only the "root" part of this "root:*:0:3::/:/sbin/sh". Pass each username through /usr/sbin/groups to identify and print user groups to a file. Then also pass each username through /usr/lbin/getprpw, and print out each users lockout=0000000 from the output of /usr/lbin/getprpw to same file so I can identify disabled accounts and for what reason based on the bit (1 or 0).
Thanks!!
Solved! Go to Solution.
- Tags:
- passwd
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 11:53 AM
07-04-2005 11:53 AM
Re: user account info
It's really quite simple to loop thorugh things like this. Here's an example shell script to do it:
OFS=$IFS
IFS=:
while read USR JUNK
do
echo $USR
done < /etc/passwd
IFS=$OFS
Inside the while loop there, you can do your 'groups' and 'getprpw' commands with $USR as the username.
If you want to use a different scripting language, then we can do that as well:
awk 'BEGIN {
OFS=FS
FS=":"
while ( getline <"/etc/passwd" ) {
print $1
}
FS=OFS
}'
Once again, within the while, you acn do what you need with $1 as the username.
OFS=$IFS
IFS=:
while read USR JUNK
do
echo $USR
done < /etc/passwd
IFS=$OFS
Inside the while loop there, you can do your 'groups' and 'getprpw' commands with $USR as the username.
If you want to use a different scripting language, then we can do that as well:
awk 'BEGIN {
OFS=FS
FS=":"
while ( getline <"/etc/passwd" ) {
print $1
}
FS=OFS
}'
Once again, within the while, you acn do what you need with $1 as the username.
One long-haired git at your service...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 01:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2005 12:29 AM
07-05-2005 12:29 AM
Re: user account info
Hi Ermin & Stuart,
Thanks for the help, both very useful and the script was great, Ermin!!
Thanks for the help, both very useful and the script was great, Ermin!!
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.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP