Solved

KSH PS1 environemnt variable

Posted on 2004-04-17
4
997 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
4 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 75 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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