1829594 Members
1336 Online
109992 Solutions
New Discussion

I cannot set PS1 prompt

 
SOLVED
Go to solution
Murat SULUHAN
Honored Contributor

I cannot set PS1 prompt

Hi

I am so sorry for this question but I cannot find the problem. I cannot set the PS1 prompt.

app1:$USER:$PWD\#PS1="$(hostname):\$USER:\$PWD\#"
app1:$USER:$PWD\#export PS1
app1:$USER:$PWD\#
app1:$USER:$PWD\#uname -a
HP-UX app1 B.11.11 U 9000/800 1883809601 unlimited-user license
app1:$USER:$PWD\#id
uid=0(root) gid=3(sys) groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7(lp),20(users)
app1:$USER:$PWD\#echo $SHELL
/sbin/sh

but I can set another setting for PS1 like that

app1:$USER:$PWD\#PS1="$(hostname):\$PWD\#"
app1:/#

but I can set same settings for another host

app2:root:/#PS1="$(hostname):\$USER:\$PWD\#"
app2:root:/#cd /usr
app2:root:/usr#

I am using copy-paste from app2 to app1 to prevent syntax errors but still have problem

Have any idea?

Best Regards
Murat
Murat Suluhan
9 REPLIES 9
Jeroen Peereboom
Honored Contributor

Re: I cannot set PS1 prompt

Murat,

try export PS1='$PWD# '
(', not ")

Will work in ksh and posix shell.

JP.
Ravi_8
Honored Contributor

Re: I cannot set PS1 prompt

Hi Murat

make entry in .profile file

export PS1='$PWD$'




never give up
Sanjay Kumar Suri
Honored Contributor

Re: I cannot set PS1 prompt

Can you set PS1 one by one i.e.

First set hostname then add $USER followed by $PWD.

sks

A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Murat SULUHAN
Honored Contributor

Re: I cannot set PS1 prompt

Hi Jeroen

yes, it works but I want to set PS1 prompt like "hostname:user-id:pwd"

We are responsible for lots of host and working with several user accounts, so my desired settings will be very helpful

the app1 cannot sets up but the app2 sets successfully, these 2 hosts are identical (works as cluster nodes)

Best Regards
Murat SULUHAN
Murat Suluhan
Jose Mosquera
Honored Contributor
Solution

Re: I cannot set PS1 prompt

Hi,

What about this:
PS1="`hostname`:\$LOGNAME\$PWD\>"

Rgds.
SAHA
Honored Contributor

Re: I cannot set PS1 prompt

Add this in /etc/profile:

PS1=`uname -n`^'$LOGNAME:$PWD > '; export PS1

Thanks,
You must PASS failure on way to success !!!
Murat SULUHAN
Honored Contributor

Re: I cannot set PS1 prompt

Hi Sanjay

app1:$USER:$PWD\#PS1="$(hostname):"
app1:PS1="$(hostname):\$USER:"
app1:$USER:

I think there is a problem with $USER variable, but I think $USER variable is built-in shell variable and don't needs to set up

When I set the $USER the PS1 works

app1:$USER:$PWD\#export USER=root
app1:root:/#

Have any idea?

Thanks for your response

Best Regards
Murat SULUHAN
Murat Suluhan
Jeroen Peereboom
Honored Contributor

Re: I cannot set PS1 prompt

Murat,

I assumed your big problem was caused by " i.s.o ' and you would be able to figure out the rest. If you use " the $PWD will be evaluated only once and not when you type 'cd directory'.

You should be aware of special characters just behind a variable name. It's safer to use ${USER}.

You can do something like:
PS1="$(hostname):$(USER}:"'${PWD}#'

JP.
Murat SULUHAN
Honored Contributor

Re: I cannot set PS1 prompt

Hi all

Jose Maria and SAHA's solutions are working,

PS1="`hostname`:\$LOGNAME\$PWD\>"
PS1=`uname -n`^'$LOGNAME:$PWD > '; export PS1

Thanks for every response

Best Regards
Murat SULUHAN
Murat Suluhan