?
Solved

KSH PS1 environemnt variable

Posted on 2004-04-17
4
Medium Priority
?
1,002 Views
Last Modified: 2013-12-26
From the ksh prompt I can enter the following to successfully change the prompt:

PS1="$(hostname) $ "

When I try this in a script it doesn't work and the prompt stays on "$". I've tried exporting it but that didn't seem to work either. I'm using UWIN if that's any help.

Thanks
0
Comment
Question by:r47463
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 225 total points
ID: 10850201
call the script like this:

. script

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10851158
Tintin is right, buy you may want an explanation for this...

Whenever you start a shell script, a new shell is started to process the script. This means that any settings you apply in the script are only active while this new shell is alive. As soon as the script ends, the shell process exits as well, and your new PS1 variable goes with it. When you use the ". script" syntax, the contents of the script are actually read into  your current shell (it's like an include command). This way, anything you do in the script will be applied to your current shell.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10852423
in your script use full path to hostname, like
PS1="$(/path/to/hostname) $ "

If you just want to use it to make the setting permanent for your shell, then you need to source it (as described before)
Or probably your want to write it in your ~/.profile
0
 

Author Comment

by:r47463
ID: 10853277
Thanks for all of your help.
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question