problem in setting PS1 variable


 
Thread Tools Search this Thread
Operating Systems Solaris problem in setting PS1 variable
# 1  
Old 02-10-2009
problem in setting PS1 variable

Hi

I have set PS1 in my profile as -
PS1='${LOGNAME}@${PWD}>' ; export PS1

it works fine if I am in bash/ksh shell, but as soon as i switch to bourn shell (sh) then it shows "${LOGNAME}@${PWD}>" as prompt.

It is also not working in csh.

Please help.
# 2  
Old 02-10-2009
I believe ${LOGNAME} ${PWD} are special ,,metacharacters'' that are interpreted by shell. bash, ksh are modern shells with a lot of capabilities, sh and csh are more simple shells that don't have all that fancy stuff.

shell is sort of programming language, in .vbs (forgive me this example here) a variable is simply wirrten like var, in perl/shell you need to write $var, what you spotted is simply one of differences between csh, sh, ksh, bash.
# 3  
Old 02-10-2009
but Togr, I believe LOGNAME and PWD are shell variables and even if you type echo ${LOGNAME} or ${PWD} in bourne shell (sh) , it will give u the result.
sorry if I am wrong.

Is it possible to have consistent prompt irrespective of shell in use.

Thanks for ur reply togr.
# 4  
Old 02-10-2009
I never worried about that much, to be honest.
I'd not be surprised if sh simply did not interpret these character the way bash does.

I tried on a FBSD (which has real sh, not linked bash) and managed something like this:
Code:
${LOGNAME} echo $PS1
${LOGNAME}
${LOGNAME} bash
[root@fbsd ~]# echo $PS1
[\u@\h \w]\$
[root@fbsd ~]# exit

this got interpreted:
Code:
${LOGNAME} PS1="${PWD}"
/root

but was assigned statically:
Code:
/root cd ..
/root

is there any particular reason or this is just an excersise for you?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem setting path to external hard drive as a variable

Hello all, I am EXTREMELY new to using bash and I have a bit of a problem: I'm trying to set up a shell script that can 1.) take one of several giant files off of an external hard drive 2.) use it as input for scripts on my laptop's hard drive ... (3 Replies)
Discussion started by: machine_spirit
3 Replies

2. UNIX for Dummies Questions & Answers

Need to revert default prompt in Linux after setting PS1 command

I have given as: PS1="Karthick>" in linux. Now the prompt changed as: Karthick> Now I need to get back the default prompt . How to achieve this? Thanks in advance (13 Replies)
Discussion started by: karthick nath
13 Replies

3. UNIX for Dummies Questions & Answers

Setting environment variable problem in Ubuntu?

I am trying to install timbl- memory based learner tools in ubuntu. it after unpacking the tar file it brings the following msg No package 'ticcutils' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you... (1 Reply)
Discussion started by: gbdaw
1 Replies

4. UNIX for Dummies Questions & Answers

setting the PS1 variable

Hi i'm new to unix, can anyone assist in me setting the PS1 variable in unix (3 Replies)
Discussion started by: user@123
3 Replies

5. UNIX for Dummies Questions & Answers

Setting PS1

I have set PSI for my prompt using the following command: PS1="${debian_chroot:+($debian_chroot)}\\u@\h:\\\w\a]\ "which produces chrisd@pguk:~]I want to include [ in the beginning but cannot understand the way to do this. Also I want to show only the current directory, not the whole... (4 Replies)
Discussion started by: kristinu
4 Replies

6. Shell Programming and Scripting

problem with setting environment variable

shell script: #!/bin/csh set VAR=12345 echo $VAR will peacefully give the output 12345 at shell. I need to use C++ to do the same in some part of the code: string str = "12345"; retValue="set var1= "+str; system(retValue1.c_str()); system("echo $var1"); This doesn't create a system... (1 Reply)
Discussion started by: harshvardhan360
1 Replies

7. Shell Programming and Scripting

Please explain below PS1 variable

please tell me what is "!" mean in below value of PS1 variable PS1='($PWD) !>' Thanks Sunny (3 Replies)
Discussion started by: sunilmenhdiratt
3 Replies

8. Shell Programming and Scripting

Help setting PS1 prompt to include current time

Hi, I'm using the ksh shell and I'd like to set my PS1 prompt on an AIX system to include, amongst ther things, the current time. This was my best effort: export PS1=$(date -u +%R)'${ME}:${PWD}# ' but this only sets the time to the value when PS1 is defined and the time value doesn't... (4 Replies)
Discussion started by: m223464
4 Replies

9. UNIX for Dummies Questions & Answers

setting PS1 variable

Hi, I am trying to set my current prompt with the current directory iam working on by $PS1=$PWD but it is blank. please help. (4 Replies)
Discussion started by: papachi
4 Replies

10. UNIX for Advanced & Expert Users

PS1 variable

I want to set my prompt to something more descriptive than a plain old $, so I set the PS1 variable as such: PS1="" Which changes the prompt correctly, but when I change directories, it does not update the prompt. So I tried this: PS1="`pwd`>" I get the same results when changing... (2 Replies)
Discussion started by: dangral
2 Replies
Login or Register to Ask a Question