GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script help
Operating System - HP-UX
1846620
Members
1582
Online
110256
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
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
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-07-2006 01:25 PM
02-07-2006 01:25 PM
Script help
I want to write a script that will read a file. the file will contain some login name. If the name is there it will say user is permitted to print other wise not permitted to print.
How can i use this condition in the following script
echo "Enter user name"
read USER
x=`grep $USER user`
How can i use this condition in the following script
echo "Enter user name"
read USER
x=`grep $USER user`
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2006 02:25 PM
02-07-2006 02:25 PM
Re: Script help
The problem with using grep is that if you are searching for 'Bill' then 'Bill', 'Billy', and 'Billie' will match. You need to use enhanced grep and do an anchored search. We are only interested in a match (status 0) or no match (non-zero) so we will use the -q (quiet) grep option.
USERFILE=myusers # file that contains the users"
typeset -i STAT=0
typeset USER=""
echo "Enter user name: \c"
read USER
grep -E -q -e "^${USER}\$" ${USERFILE}
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "${USER} OK"
else
echo "${USER} Bad"
fi
USERFILE=myusers # file that contains the users"
typeset -i STAT=0
typeset USER=""
echo "Enter user name: \c"
read USER
grep -E -q -e "^${USER}\$" ${USERFILE}
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "${USER} OK"
else
echo "${USER} Bad"
fi
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2006 03:13 PM
02-07-2006 03:13 PM
Re: Script help
solved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2006 07:22 PM
02-07-2006 07:22 PM
Re: Script help
Hi,
Did you check your profile?
I have assigned points to 18 of 55 responses to my questions.
Try to assign points to reach 55 of 55 responses.
And,
Try to close the thread with answer you got.
--
Muthu
Did you check your profile?
I have assigned points to 18 of 55 responses to my questions.
Try to assign points to reach 55 of 55 responses.
And,
Try to close the thread with answer you got.
--
Muthu
Easy to suggest when don't know about the problem!
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
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP