- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh88, hpterm, dynamic PS1 troubles
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-15-2010 02:26 PM
10-15-2010 02:26 PM
ksh88, hpterm, dynamic PS1 troubles
I cannot figure out how to get my PS1 variable to have dynamic information. I know I have to use ' instead of "" but when I use ' $(...) does not work.
I tried this and it didn't work: http://forums11.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0xa0ead211e18ad5118ff10090279cd0f9%2C00.html&admit=109447626+1287181133657+28353475
When I use ' shell variables like $PWD work and update but I can't get the current time in there. And I'm also trying to put in a new line with "\n" but that doesn't work either.
Any ideas anyone?
168:
168:
HP-UX
169:
170:
171:
172:
173:
"${_d[_s]}$_x1:$_x2:$_x3"
- Tags:
- PS1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2010 03:20 PM
10-15-2010 03:20 PM
Re: ksh88, hpterm, dynamic PS1 troubles
First, Robin's code post was mangled during a Forum update years ago. The '[' and ']' are left and right square brackets, respectively.
typeset -RZ2 _x1 _x2 _x3
let SECONDS=$(date '+3600*%H+60*%M+%S')
_s='(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)'
TIME='"${_d[_s]}$_x1:$_x2:$_x3"'
export PS1=${TIME}
Second, if I recall correctly, the post shown only works for the Korn shell. The '$(...)' notation is a POSIX standard that may not apply.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2010 03:27 PM
10-15-2010 03:27 PM
Re: ksh88, hpterm, dynamic PS1 troubles
$ typeset -RZ2 _x1 _x2 _x3
$
$ let SECONDS=$(date '+3600*%H+60*%M+%S')
$
$ _s='(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)'
$
$ TIME='"${_d[_s]}$_x1:$_x2:$_x3"'
$
$ export PS1=${TIME}
"${_d[_s]}$_x1:$_x2:$_x3"
So is there anyway to do $(...) in KSH88 on an HP-UX box?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2010 02:49 AM
10-16-2010 02:49 AM
Re: ksh88, hpterm, dynamic PS1 troubles
ksh is a real shell, $() works perfectly fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2010 07:40 PM
10-16-2010 07:40 PM
Re: ksh88, hpterm, dynamic PS1 troubles
Sure:
export PS1="$(date +"%I:%M:%S %p")
$ "
\n is not available when evaluating the PS1 contents. If you need a newline, include it in the definition like the above example. Be sure you look at the intermediate results before you assign it to PS1.
> export PS1=${TIME}
This will simply assign the current value of the variable $TIME. It will not execute any of the TIME=... instructions.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2010 04:42 PM
10-17-2010 04:42 PM
Re: ksh88, hpterm, dynamic PS1 troubles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2010 05:48 PM
10-17-2010 05:48 PM
Re: ksh88, hpterm, dynamic PS1 troubles
export PS1='$(date +"%I:%M:%S %p")
$ '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2010 06:21 PM
10-17-2010 06:21 PM
Re: ksh88, hpterm, dynamic PS1 troubles
You are right of course. Single quotes will return the current contents of variables:
PS1='$SECONDS $'
However, the shell will not process $(..) or `...` or update a static variable. However, the example you mentioned takes advantage of the shell's expansion of integers, specifically when the integer contains the name of a variable. Here's a reference that you were probably using:
http://software.itags.org/bsd/46709/
Following the example, I was not able to get ksh (ksh-1988) to work (PS1 just had the _time expression) but dtksh (ksh-1993 found at /usr/dt/bin/dtksh) returns a static value. Looks like a fair amount of troubleshooting will be needed.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2010 06:42 PM
10-17-2010 06:42 PM
Re: ksh88, hpterm, dynamic PS1 troubles
export PS1='$(date +"%I:%M:%S %p")
$ '
I tried this on 11.00 through 11.31, POSIX sh, ksh (ksh-1988) and dtksh (ksh-1993), but it only worked with dtksh (ksh-1993). Looks like $(...) may have been enhanced in ksh93 for PS1 expansion.
Bill Hassell, sysadmin