- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: posix shell and PS1 values
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
тАО02-09-2004 09:25 PM
тАО02-09-2004 09:25 PM
Thank You
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:36 PM
тАО02-09-2004 09:36 PM
Re: posix shell and PS1 values
I know how to assign the hostname and current directory:
export PS1="`hostname`"'$PWD> '
It is important that $PWD is surrounded by ' and not ".
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:36 PM
тАО02-09-2004 09:36 PM
Re: posix shell and PS1 values
export PS1
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:41 PM
тАО02-09-2004 09:41 PM
Re: posix shell and PS1 values
http://www.oreilly.com/catalog/upt3/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:41 PM
тАО02-09-2004 09:41 PM
Re: posix shell and PS1 values
PS1='
export PS1
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:42 PM
тАО02-09-2004 09:42 PM
Re: posix shell and PS1 values
Does it exist?
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 09:58 PM
тАО02-09-2004 09:58 PM
Re: posix shell and PS1 values
Example with vis to show characters
Line numbers to help extraction
1 #!/usr/bin/ksh
2 # Make certain that the length of time fields is 2-digit:
3 #set -x
4 typeset -RZ2 hr min sec
5
6 # Get a string which is parsable to the number of seconds.
7 let SECONDS=$(/usr/bin/date '+3600*%H+60*%M+%S')
8
9 s='(hr=(SECONDS/3600)%24)==(min=(SECONDS/60)%60)==(sec=SECONDS%60)'
10 d=
11 TIME='"${d[s]}$hr:$min:$sec"'
12 #export MESSAGE=\\${TIME}':'"On "\\$PWD" "\\$MESSAGE
13 #echo $TIME $MESSAGE
14 echo "\e&v4S $LOGNAME \e&v5S $(uname -nmrv) \e&v2S:\e&v4S $MESSAGE
15 \e&v5S\\$PWD\e&v1S >\e&v0S
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2004 11:22 PM
тАО02-09-2004 11:22 PM
Re: posix shell and PS1 values
bash has more 'built-in' variables for the prompt than ksh or sh-posix. I can remember reading an article on ksh, which listed the code for a time in the PS1 pronpt. I didn't understand it. I think the next url refers to that article:
http://www.itworld.com/AppDev/1458/swol-0316-regex/
Quote:
Portable shell
ksh93 is freely available for essentially all Unixes, and also, with light license restrictions, for Windows and MVS. A handful of vendors support ksh93 commercially. Korn's team at AT&T plans to upgrade a future release of KornShell with a combination of object inheritance, support for binary objects, and namespaces. Also for that release, Korn writes, "Multithreading is a possibility, but less likely than the others."
Korn has even made much of the contents of his authoritative reference book on ksh available for download. Here's an example fragment, which gives an idea of ksh's syntax and functionality:
# Set SECONDS to number of seconds since midnight.
export SECONDS="$(date '+3600*%H+60*%M+%S')"
# The following variables store hours and minutes.
typeset -Z2 _h _m # Two columns, leading zeros.
# The following expression reformats SECONDS.
_time='$((_h=(SECONDS/3600)%24)):$((_m=(SECONDS/60)%60))'
# Use _time within PS1 to get the time of day.
PS1="($_time)"'!$ '
# Note that $_time gets replaced by above expression.
# Expression gets evaluated when PS1 is displayed.
This example is particularly interesting as an example of language evolution. In 1999, after the book was published, ksh's printf operation was augmented to include new time capabilities. A consequence is that all the code above can now be abbreviated to the single line:
PS1='$(printf "(%(%H:%M)T)!$ " now)'
End Quote.
Looks similar to Steve's reply.
Hope this helps,
JP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-10-2004 12:58 AM
тАО02-10-2004 12:58 AM
SolutionSetting and Referencing Variables:
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90164/B2355-90164_top.html&con=/hpux/onlinedocs/B2355-90164/00/00/41-con.html&toc=/hpux/onlinedocs/B2355-90164/00/00/41-toc.html&searchterms=PS1&queryid=20040210-064956
This is what I do:
HOST=`uname -n`
PS1="\$HOST:\$LOGNAME:\$PWD # ";export PS1
There's another example here:
http://www.nersc.no/~knutal/unix_tips.html
Rgds...Geoff