Hostname displays incorrectly

hiii,

in many of the linux machines i have tried this but the result is the same everywhere.

if there are double letters in a hostname then that is displayed as single letter.

e.g. if hostname is set to nepttune then login into the shell will display :

NEPTUNE(admin)@/ [20]
$ hostname
nepttune
NEPTUNE(admin)@/ [21]
$ uname -n
nepttune
NEPTUNE(admin)@/ [22]
$

even if i do ssh from some other then also it will not display correct hostname with double letters repeating but only single letter.
any consequetive double letters are always displayed as single letter.
but if u type the command "hostname" or "uname -n" then it will display the correct hostname.

can anyone plz tell if there is any solution to this ?

hiii,

in many of the linux machines i have tried this but the result is the same everywhere.

if there are double letters in a hostname then that is displayed as single letter.

e.g. if hostname is set to nepttune then login into the shell will display :

NEPTUNE(admin)@/ [20]
$ hostname
nepttune
NEPTUNE(admin)@/ [21]
$ uname -n
nepttune
NEPTUNE(admin)@/ [22]
$

even if i do ssh from some other then also it will not display correct hostname with double letters repeating but only single letter.
any consequetive double letters are always displayed as single letter.
but if u type the command "hostname" or "uname -n" then it will display the correct hostname.

can anyone plz tell if there is any solution to this ?

Your correct hostname is what is displayed on running 'hostname' or 'uname -n' commands. Are you using DNS for hostname resolution? If so, then it is probably a mistake on the DNS server.

shamik, do not create multiple threads for a single subject. I have merged the threads.

No,
we are not using any DNS for name resolution. I just dont understand how to solve this problem.

How do you connect to the server (via telnet/ssh)? Using the IP address directly?

i connect to the server from my win xp machine through ip address directly using telnet.

Then what is the problem? Is it that the shell is showing NEPTUNE instead of nepttune? You can change that quite easily. In bash this might help:

PS1=$(uname -n):"$PWD# "; export PS1

just see the impact of the command u suggested.

NEPTUNE(admin)@/usr/ [46]
$ PS1=$(uname -n):"$PWD# "; export PS1
nepttune:/usr/#

It is showing the correct hostname...................nodobout about it.
But can you see that now I am not able to see the current user (previously admin) and also the current directory (previously /usr/)

cant I do it by keeping everything as it is ??

There's also a good chance that NEPTUNE is hardcoded in some profile or related login script. Hostnames don't get converted to uppercase or misspelled by design of the OS.

I was going to suggest that too, ie. the name in uppercase is a simple hard-coded string in someone's "PS1", rather than anything to do with the machine's hostname setting.
PS1 can be set in "/etc/profile", the user's ".profile", their ".bashrc", possible ".kshrc", and any other scripts they have set up to be called during login.

(Also that splitting of the prompt into 2 lines is not very pretty.)

Hey, there is nothing wrong with splitting the prompt into two lines. The first line is a "status line" and the second line is simply the prompt character. I do all of my prompts this way, mostly because drilling down into a deeply nested subdirectory leaves little room on the line to type commands!

But I would agree with the other comments..."nepttune" is the actual hostname, since that's what returns from the hostname and uname commands. If it quacks like a duck, it's a duck. The "NEPTUNE" is coming from somewhere else.

You're right - it's a preference thing.

I don't like a long prompt, so I trim down the path to just the last directory name; I use:

PS1="$(uname -n):\${PWD##*/}(!)$ "

I find that is both compact and informative.

The issue with two-line prompts (for me) is that you're wasting screen lines.

If you want to get really clever, you can issue colour change directives in the prompt, or even set the window title.
But that tends to fall apart if you use a different shell or terminal emulator.

This is simple to solve:

typeset HOST=$(hostname -s)

case $TERM in
     aixterm)
          PS1='^[];$LOGNAME@$HOST:$PWD^G^M# '
          ;;

     dtterm)
          PS1='^[]0;$LOGNAME@$HOST:$PWD^G^M# '
          ;;

     xterm)
          PS1='^[];$LOGNAME@$HOST:$PWD^G^M# '
          ;;


     vt100|ansi)
          PS1='$IFS$LOGNAME@$HOST:$PWD$IFS# '
          ;;

     *)
          PS1='$IFS$LOGNAME@$HOST:$PWD$IFS# '
          ;;

esac
export PS1

Notice, that the "^[", "^G" and "^M" are single characters, which have to be typed in via "CTRL-V".

bakunin

Thankyou all

The problem is finally solved.

The analysis done above is absolutely correct. Hostname was hardcoded in .profile file.

I have replaced the string

SYSNAME=`uname -n | tr -s '[:lower:]' '[:upper:]'`

with

SYSNAME=`uname -n | tr '[:lower:]' '[:upper:]'`

Thanks.

thanks for the soln....