Operating System - HP-UX
1753946 Members
8771 Online
108811 Solutions
New Discussion юеВ

banner before login promt ? Always knowing !

 
SOLVED
Go to solution
someone_4
Honored Contributor

banner before login promt ? Always knowing !

I would like to know if there is a way to put a banner out before the login promt saying the hostname. I can do it in the .profile , but that only puts up the banner after you login. And I would like to do it before the login. I have also seen where the hostname is always where the curser is IE # .The issue is i want users to always know what box they are in. We had an issue where someone thought they were in a differnt box , im sure you know how that story goes.
10 REPLIES 10
Rodney Hills
Honored Contributor
Solution

Re: banner before login promt ? Always knowing !

The file /etc/issue is used to display whatever text you like (see man issue).

And if you modify the telnet entry in the /etc/inetd.conf file to read as follows, telnet users will get it too.

telnet stream tcp nowait root /usr/lbin/telnetd telnetd -b /etc/issue
There be dragons...
Carlos Fernandez Riera
Honored Contributor

Re: banner before login promt ? Always knowing !

add -b option to /etc/inetd.conf

Then run inetd -c to reread configuration.


See man inetd

telnet stream tcp nowait root /usr/lbin/telnetd telnetd -b /etc/issue
unsupported
Rita C Workman
Honored Contributor

Re: banner before login promt ? Always knowing !

As was mentioned the /etc/issue is usually used to display the hostname...you can also use the /etc/motd for Message of the Day display type things...
As for getting the other item you mentioned. You need to edit the users .profile and add somthing like this:
PS1='$HOSTNAME:$PWD >'
export PS1

Now that greater than sign can be anything you want, most folks like a $, but each to his own...

/rcw

...and it only took me about a dozen times to get in on this post...every other one was a SSI error..go figure
Curtis Larson
Trusted Contributor

Re: banner before login promt ? Always knowing !

and to put the hostname where the cursor is you need to set the PS1 environment variable apporpriately. like this

HOSTNAME=standalone
PROMPT="$"
SMUL=""
RMUL=""

[[ -x /usr/bin/hostname ]] && HOSTNAME=$(/usr/bin/hostname)

[[ -x /usr/bin/tput ]] && SMUL=$(/usr/bin/tput smul)
[[ -x /usr/bin/tput ]] && RMUL=$(/usr/bin/tput rmul)

file=/usr/bin/id
if [ -x $file ] ;then
[[ $($file -un) = "root" ]] && PROMPT="#"
fi
PS1='${LOGNAME}@${HOSTNAME}:${SMUL}${PWD}${RMUL}
${PROMPT} '

you can put in /etc/profile to effect every user or have each user put it into their ~/.profile file for a per user implementation
Rodney Hills
Honored Contributor

Re: banner before login promt ? Always knowing !

To add to the PS1 definition, I like the following:

loginhost=`uname -n`
export PS1='$loginhost ${PWD##*/} $ '

Just having $PWD can display quite a long string, whereas PWD##*/ will only display the current directory name.
There be dragons...
Patrick Wallek
Honored Contributor

Re: banner before login promt ? Always knowing !

The point about wanting the hostname at the login prompt can be solved by adding the variable PS1 and whatever else you want to your .profile or .shrc file.

The following is my PS1 entry from my .shrc for root:

export PS1='[$HOST:$LOGNAME] ! $PWD

which makes my prompt look like:

[scrooge:root] 388 /home/wallek
#

Yes the # is supposed to be on the next line. The '!' in the export denotes the CR/LF. $PWD is always your current directory.
Patrick Wallek
Honored Contributor

Re: banner before login promt ? Always knowing !

Here's my PS1 entry from /.shrc for root

export HOST=`uname -n`
export PS1='[$HOST:$LOGNAME] ! $PWD
# '

Yes it does span two lines. The # is on the second line.

It makes my prompt look like:

[scrooge:root] 390 /home/wallek
#

If my previous reply to this thread show up, ignore it. I didn't get everything correct in it.
someone_4
Honored Contributor

Re: banner before login promt ? Always knowing !

I got it to work and was even able to add the
working dir (pwd) at the curser editing the
/ect/profile like this

HOST="(`hostname |cut -d"." -f1`)"

if [ "$LOGNAME" = "root" ]; then
PROMPT="#"
else
PROMPT=">"
fi

PS1='${HOST} ${PWD}${PROMPT} '
PS2='${HOST} ${PWD}> '
export PS1 PS2
trap 1 2 3
Steve Post
Trusted Contributor

Re: banner before login promt ? Always knowing !

Don't put the PS1 is the user's .profile. Put it in /etc/profile. That way EVERYONE gets it.
I used to have three things:
1. banner hostname
2. PS1=....
3. /usr/games/fortune
That way people had a nice fortune cookie to read as they are logging in.