- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- HPUX11.11 - Using the script command and logname -...
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
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-25-2010 04:18 AM
тАО03-25-2010 04:18 AM
I am trying to use logname having started a script command and it comes back with:
# script me
Script started, file is me
# logname
logname: could not get login name
However come out of the script command and all is fine:
# script me
Script started, file is me
# logname
logname: could not get login name
#
Script done, file is me
# logname
mparsons
Is there a workaround for this?
Kind Regards,
Mark P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 05:03 AM
тАО03-25-2010 05:03 AM
Re: HPUX11.11 - Using the script command and logname - error is "could not get login name"
Try both:
a)
LOGNAME=`logname`
print $LOGNAME
b)
LOGNAME=$(logname)
print $LOGNAME
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 06:12 AM
тАО03-25-2010 06:12 AM
Re: HPUX11.11 - Using the script command and logname - error is "could not get login name"
The 'script' command starts a new shell process. When this process uses 'logname' to attempt to obtain the login terminal name, 'getlogin()' is called to find the name of the user logged in on a terminal associated with the calling process. This is done by searching the accounting database 'utmpx'. Since at that point, the process id of the 'script' command can't be matched, 'logname' fails.
You need to take the 'LOGNAME' variable from your environement, instead:
# echo ${LOGNAME}
Regards!
...JRF...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 07:51 AM
тАО03-25-2010 07:51 AM
Re: HPUX11.11 - Using the script command and logname - error is "could not get login name"
The oracle account can only be accessed by relevant users and not as a direct login so I've got the following set in /etc/profile:
name=`logname`
if [ $name = oracle ]
then
echo $LOGNAME not allowed to login...only su
exit 0
fi
end
I'm also doing an audit trail on the relevant users by using the script command so this is part of the users profile:
Date=`date +'%Y%m%d%H%M%S'`
script /logs/script/$LOGNAME.$Date 2>/dev/null
So oracle cannot login direct. The user logs in direct - the session is copied into the script - then they do the "su - oracle" and then from the /etc/profile gets the message:
logname: could not get login name
Obviously the su login process and the script continues successfully - I just want to get rid of the "logname: could not get login name" message - anything will do!
Kind Regards,
Mark P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 09:54 AM
тАО03-25-2010 09:54 AM
Re: HPUX11.11 - Using the script command and logname - error is "could not get login name"
is not the same as
su oracle
'-' means accept a new oracle environment
without means maintain the current environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 01:58 PM
тАО03-25-2010 01:58 PM
Solution> "logname: could not get login name"
> message - anything will do!
> name=`logname`
name=` logname 2> /dev/null `
dyi # script
Script started, file is typescript
dyi # name=` logname `
logname: could not get login name
dyi # name=` logname 2> /dev/null `
dyi #
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 03:20 AM
тАО03-26-2010 03:20 AM
Re: HPUX11.11 - Using the script command and logname - error is "could not get login name"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 03:22 AM
тАО03-26-2010 03:22 AM