Operating System - HP-UX
1834394 Members
1569 Online
110066 Solutions
New Discussion

Re: Cannot set command prompt (ver. 10.20)

 
Sergio E. Tapia
New Member

Cannot set command prompt (ver. 10.20)

I try to assign a value to the PS1 variable as a regular user in 10.20, and the system shows this error message:

-sh: PS1="whatever" is not an identifier

When I try to do the same thing as root, the system shows this message:

sh: Syntax error: 'newline or ;' is not expected.

The exact command I'm trying to execute is:

export PS1="$LOGNAME@$(hostname):\$PWD>"

and it works fine on another 10.20 system I have running.

TIA
11 REPLIES 11
Steven Sim Kok Leong
Honored Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi,

What is the login shell used for your normal user account? Check the environment settings for the user:

# env

Hope this helps. Regards.

Steven Sim Kok Leong
Animesh Chakraborty
Honored Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi,
You can try this way.
# set prompt
host=`hostname`;
usr=`whoami`
PS1="${host}:${usr}->"; export PS1
Did you take a backup?
Trond Haugen
Honored Contributor

Re: Cannot set command prompt (ver. 10.20)

Could there be some problem with $LOGNAME or $PWD not being set properly?
What does echo "$LOGNAME@$(hostname):\$PWD" yield?

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
ian Dennison
Regular Advisor

Re: Cannot set command prompt (ver. 10.20)

If your Shell is a 'csh', the command will be different for setting the prompt.

Try 'set prompt = "text"' when logged on as the User, if using the C shell.

Once you have identified the correct format string, place the string in either .profile or .cshrc in the Users home directory (depending on what shell you are using).

Share and Enjoy! Ian
Lets do it to them before they do it to us! www.fred.net.nz
Vincent Stedema
Esteemed Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi,

AFAIK, the POSIX shell (sh) doesn't recognize the "export VAR=VALUE" format. You have to set and export the variable separately.

Like this:

PS1="$LOGNAME@$(hostname):\$PWD>"
export PS1

--OR--

PS1="$LOGNAME@$(hostname):\$PWD>" export PS1

The format you use WILL work with the Korn shell.

Regards,

Vincent
Thierry Poels_1
Honored Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi,

Posix (sh), like Korn shell (ksh), does support "export var=value".
Bourne shell (also sh) does not, and therefore "var=value; export var" is required.
BTW C-shell (csh) uses a different syntax "setenv var value".

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Satish Y
Trusted Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi Sergio,

May be one of the following possibilities,

Typo.
(or)
'@' is set as kill or intr char in ur system.
(or)
Using Bourne shell.

Hope it helps,

Cheers...
Satish.
Difference between good and the best is only a little effort
Peter Kloetgen
Esteemed Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi Sergio,

is it possible, that you use a Bourne Shell?
if the answer is yes, you have a syntax problem, becaus of the command substitution. Try the following:

PS1=$LOGNAME'@'`hostname`:'$PWD'>

export PS1


I think this should work on all shells except C- shells.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Sergio E. Tapia
New Member

Re: Cannot set command prompt (ver. 10.20)

Hi, everybody!!!

Thank you all for your suggestions. As one of you guys mentioned, I have a problem with my variables. I tried:

# echo $PWD
and
# echo $(hostname)

and neither one has a value assigned to; but:

# echo $LOGNAME

returns the correct value.

I double-checked for syntax errors, and that seems to be OK.

I'll try replacing the shell I'm using for regular users (/usr/bin/sh), since that can also be part of the problem. Which brings another question: Can I just copy the shell from another server using the same OS (10.20)?

Thanx again!!!
Bill Hassell
Honored Contributor

Re: Cannot set command prompt (ver. 10.20)

> # echo $PWD
> and
> # echo $(hostname)
> and neither one has a value assigned to

Wow, that is not good at all. $PWD is provided in all supported shells. And echo $(hostnme) will produce exactly the same results as the command: hostname

So, if someone has 'improved' the system by replacing /usr/bin/sh, you've got big problems as many system scripts depend on /usr/bin/sh. If users want non-standard shells, they can either login normally and start their favorite shell, or put: exec favorite_shell at the end of .profile, or they can change their shell with the chsh command.

Someone was probably confused about the Bourne, Korn, and Posix shells. Copying the binary file /usr/bin/sh from another system is OK as long as they are the same revision of HP-UX. There may be corner cases with patches.

Don't modify the /usr/bin (or /usr/sbin or /sbin) directories unless you are very familiar with HP-UX commands. Use the above techniques for customization.


Bill Hassell, sysadmin
Peter Kloetgen
Esteemed Contributor

Re: Cannot set command prompt (ver. 10.20)

Hi Sergio,

here some pathes and the shells belonging to them:

/usr/bin/sh --> POSIX shell
/usr/bin/ksh --> Korn shell (like POSIX shell )
/usr/old/bin/sh --> Bourne shell
/usr/bin/csh --> California shell
/sbin/sh --> superuser shell

In most cases the POSIX shell is used on HP-UX computers.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping