Solved

KSH PS1 environemnt variable

Posted on 2004-04-17
4
993 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
Comment Utility
call the script like this:

. script

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for all of your help.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 111
matchUp  challenge 6 48
haveThree challenge 22 100
matchUp  challenge 9 70
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now