- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to write a script to find out whether one ...
Operating System - HP-UX
1753888
Members
7682
Online
108809
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
тАО02-01-2011 07:32 AM
тАО02-01-2011 07:32 AM
How to write a script to find out whether one user id is available or not
Hi All,
I would like to write a script to find out whether one user id is available or not...
And I would like to print the message "User is available" / "User is not available".
I would like to write a script to find out whether one user id is available or not...
And I would like to print the message "User is available" / "User is not available".
- Tags:
- passwd
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2011 07:48 AM
тАО02-01-2011 07:48 AM
Re: How to write a script to find out whether one user id is available or not
Hi Senthil:
# USER=senthil
# grep -q ^${USER}: /etc/passwd && echo "Valid" || echo "Invalid"
...set the value of 'USER' accordingly.
Regards!
...JRF...
# USER=senthil
# grep -q ^${USER}: /etc/passwd && echo "Valid" || echo "Invalid"
...set the value of 'USER' accordingly.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2011 07:56 AM
тАО02-01-2011 07:56 AM
Re: How to write a script to find out whether one user id is available or not
Hi (again):
If you meant a UID (e.g. 1000) then this variation would suffice:
# UID=1000
# grep ^.*:.*:${UID}: /etc/passwd && echo "Present" || echo "Open"
Regards!
...JRF...
If you meant a UID (e.g. 1000) then this variation would suffice:
# UID=1000
# grep ^.*:.*:${UID}: /etc/passwd && echo "Present" || echo "Open"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2011 08:08 AM
тАО02-01-2011 08:08 AM
Re: How to write a script to find out whether one user id is available or not
Shalom,
Some Unix/Linux systems will not allow the same text Id to be used twice. Ran into that on Solaris.
avail.sh
echo "enter desired id:"
read idhold
echo "Enter desired uid:"
read uidhold
foundid=$(grep $idhold /etc/passwd |wc -l)
founduid=$(grep $uidhold /etc/passwd |wc -l)
if [ $foundid -eq 0 && $founduid -eq 0 ]
then
echo "Good to go with $idhold $uidhold "
else
echo "Bad admin, no re-use of ids..."
fi
Obviously tune your message to the actual users of the scripts.
Some Unix/Linux systems will not allow the same text Id to be used twice. Ran into that on Solaris.
avail.sh
echo "enter desired id:"
read idhold
echo "Enter desired uid:"
read uidhold
foundid=$(grep $idhold /etc/passwd |wc -l)
founduid=$(grep $uidhold /etc/passwd |wc -l)
if [ $foundid -eq 0 && $founduid -eq 0 ]
then
echo "Good to go with $idhold $uidhold "
else
echo "Bad admin, no re-use of ids..."
fi
Obviously tune your message to the actual users of the scripts.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
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