- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Posix shell : login name in prompt
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
Forums
Discussions
Discussions
Discussions
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
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
10-31-2002 03:34 AM
10-31-2002 03:34 AM
Posix shell : login name in prompt
I wants 2 display my login name in the Posix shell prompt :
jack$ id -un
jack
jack$ su joe
joe$ exit
jack$
With Solaris, AIX, Dynix/ptx, Linux (with korn shell, bash has \u), it can b done with :
export ENV=$HOME/.shrc
in $HOME/.shrc :
export PS1=`id -un`"$ "
With HP-UX, as mentioned in su(1), the ENV environment variable is removed. So it can't work !
Any workaround ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 03:43 AM
10-31-2002 03:43 AM
Re: Posix shell : login name in prompt
Try this in your ~/.profile
export PS1="[$(whoami)] $(hostname):\$PWD\> "
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 03:48 AM
10-31-2002 03:48 AM
Re: Posix shell : login name in prompt
PS1=`hostname`"@"`logname`"#"
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 03:54 AM
10-31-2002 03:54 AM
Re: Posix shell : login name in prompt
Why not
whoami
??
or
echo $LOGNAME
?? which works with hpux, aix, and solaris.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 05:18 AM
10-31-2002 05:18 AM
Re: Posix shell : login name in prompt
Your solutions don't work.
2. whoami is equivalent 2 id -un but doesn't exist on Dynix/ptx.
3. With Solaris, AIX, etc., su does'nt unset $ENV, so $HOME/.shrc is source and PS1 is assigned properly (i.d. id -un is executed)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 05:33 AM
10-31-2002 05:33 AM
Re: Posix shell : login name in prompt
PS1=`/usr/xpg4/bin/id -un`"$"
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 05:51 AM
10-31-2002 05:51 AM
Re: Posix shell : login name in prompt
i'm on HP-UX 11.0
but it doesn't matter : your solution seems not to work.
To reflect login name in PS1, i think it can't be done in .profile because .profile ISN'T reread after su. Only the script mentioned with $ENV is reread, but su/HP-UX unset it !!!
Any idea ?
Cyril.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 06:29 AM
10-31-2002 06:29 AM
Re: Posix shell : login name in prompt
it is right that "su
You can write this lines in /etc/profile than every user has the new prompt (even after a "su
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2002 07:04 AM
10-31-2002 07:04 AM
Re: Posix shell : login name in prompt
/etc/profile isn't read after su just "su -"
i want my prompt changes everytime i do a su (not only a "su -") like in my example.