- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to find a user ID from a shell script
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
Discussions
Discussions
Discussions
Forums
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
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
тАО03-01-2001 03:23 AM
тАО03-01-2001 03:23 AM
and store that in a variable ?
we are using HP-ux 10.20
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 03:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 03:38 AM
тАО03-01-2001 03:38 AM
Re: How to find a user ID from a shell script
echo $LOGNAME
will also give you what you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 03:41 AM
тАО03-01-2001 03:41 AM
Re: How to find a user ID from a shell script
#user_id=`id -u ` ( variable that stores the user id -> 0 for root )
# user_account=`id -nu` ( variable that stores the account )
federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 03:42 AM
тАО03-01-2001 03:42 AM
Re: How to find a user ID from a shell script
which is better to be used with elm to send a file (a report that the user invoked or a message that something happened) ?
are both solutions equally valid ?
Sorry if I woke you up !!!! But you have to get up sometime !!!!!!!!!!.
Thanks again. Have a good day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 03:54 AM
тАО03-01-2001 03:54 AM
Re: How to find a user ID from a shell script
Please clarify what it is you need to do...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 04:07 AM
тАО03-01-2001 04:07 AM
Re: How to find a user ID from a shell script
a user logs in to hpux based application.
user runs a command from the application (which for eg: generates a report). This user should receive the report in his e-mail. From the application a shell script will be invoked to run the report or to generate the message.
The userid within the application and UNIX are identical. Infact the application picks it up from UNIX.
so what I would like to know is who ran the script so that within the script I can say
"elm $logname" ?
Have I confused you further ? I hope not.
I am not certain what caffeine does to a confused mind. But some Jack Daniels may help !!!!
have a good day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 04:14 AM
тАО03-01-2001 04:14 AM
Re: How to find a user ID from a shell script
just another solution:
elm `whoami` ...
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 04:30 AM
тАО03-01-2001 04:30 AM
Re: How to find a user ID from a shell script
1. The user logs in to an application.
2. The application generates a report
3. The application calls a script to e-mail the report to the user
Then yes, invoking "elm $LOGNAME" should send e-mail to your user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 04:45 AM
тАО03-01-2001 04:45 AM
Re: How to find a user ID from a shell script
Thanks for all the good suggestions.
JIm I will go with your suggestion. However with a small change.
elm $logname does not work for some reason
It should be elm $$logname.
This is not the full solution as the elm editor pops up even with the above command.
I have to find a way to stop it.
The mail is then routed through smtp to NOtes!! where the user while eating his breakfast or sipping his cup of tea gets to read the report while we toil in the engine room !!!!.
Thanks again guys.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 04:58 AM
тАО03-01-2001 04:58 AM
Re: How to find a user ID from a shell script
Here are much easiest methos in a script:
cat report_name | mailx -s"Some subject" $LOGNAME
cat report_name | mailx -s"Some subject" $(/usr/bin/id -nu)
I think of mailx as the script mailer...only 3 things are required: -s"a useful subject", the email address and stdin with the text needing to be mailed.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 05:16 AM
тАО03-01-2001 05:16 AM
Re: How to find a user ID from a shell script
My apologies for saying $LOGNAME doesnot work.
However when I use mailx it gives a strange message to say "The flags you gave are used only when sending mail.""
/usr/bin/id not found !!!!.
Is there a central place within ux 10.2 where I can define the smtp mail addresses of the users that can be accessed by mailx or elm as aliasses ?
Else I will have to type in the lot in the script with a if/case structure.
Thanks again for all the support.
I am trying to save some trees !!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 06:03 AM
тАО03-01-2001 06:03 AM
Re: How to find a user ID from a shell script
user=`whoami`
report=/dir/dir/dir/reportname
mailx -s "subject" ${user} < ${report}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 01:02 PM
тАО03-01-2001 01:02 PM
Re: How to find a user ID from a shell script
echo "User is $LOGNAME" | mail root &
However mailx with the following syntax should work.
echo "User is $LOGNAME" | mailx -s 'Someone has used your script' user@mail.domain.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2001 08:02 PM
тАО03-01-2001 08:02 PM
Re: How to find a user ID from a shell script
That is the correct pathname for the id command on HP-UX 10.xx. What happens when you type id? It it reports your id information, type the command:
whence -v id
/usr/bin/id must exist (along with hundreds of other commands)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2001 12:20 AM
тАО03-02-2001 12:20 AM
Re: How to find a user ID from a shell script
I've found out that some users (on HP-UX 10.20) are clever enough to run certain scripts as if the are another user. When using options above you can find out the user they have become.
If you use
" who -m "
you will find out the first login id.
If you have prevented you system against login as root user and anyone needs to login by there own name first, you will be able to track down the write user. To mail the outcome, just use on of the options above.
Regards.