Solved

KSH PS1 environemnt variable

Posted on 2004-04-17
4
1,000 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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