Operating System - HP-UX
1753878 Members
7142 Online
108809 Solutions
New Discussion юеВ

Re: trap "echo 'logout'" 0 in 11.31

 
Candace Pettit
Advisor

trap "echo 'logout'" 0 in 11.31

Good evening everyone,

My company recently upgraded from 11.00 to 11.31. Previously, "logout" would appear when our users typed "exit" in the telnet window they were using to access our HP-UX system.

We have the line trap "echo 'logout'" 0 in the .profiles on both the 11.00 system and the 11.31 system. The "logout" message appears on the 11.00 system, but not the 11.31 system.

The shell still exits properly, as we get the message from our telnet program, Procomm Plus, that it has disconnected. We just do not get the "logout" message that used to execute when a shell exit signal was trapped.

Does anyone know if this ability was either removed in 11.31, or perhaps the syntax needed has changed?
5 REPLIES 5
Raj D.
Honored Contributor

Re: trap "echo 'logout'" 0 in 11.31

Candace,

The trap command is ok, and it should work as it is working on 11.00 system,
trap is part of the shell. # man sh-posix will have more info.

-What do you see when you just type trap command in the shell.
- what sheel you are using:
$ echo $SHELL

- what happens if you try :
trap "echo 'LOGOUT'" 0

$ Ctrl+d # or type # exit #to check.


Hth,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: trap "echo 'logout'" 0 in 11.31

Candance,

Your command looks good and should produce the desired output if you are using correct shell,

- you can try the follwing once you logged in to the account:
$ /usr/bin/sh
$ trap "date " 0
$ exit

[ Do you see the date output.. ]



- Also you can try the following:
$ /usr/bin/sh
$ trap "printf 'LOGOUT\n'" 0
$ exit

[ Do you see the LOGOUT output.. ]





Also check out this page:
http://www.docs.hp.com/en/B2355-90046/ch23s07.html

Hth,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Bill Hassell
Honored Contributor

Re: trap "echo 'logout'" 0 in 11.31

The action specified is valid for a trap result, so it may be your terminal emulator. When you exit from a session, does the window disappear or does it stay until you manually close it? Many terminal emulators have the option to close when telnet is finished. It's possible that Procomm is closing the window so fast that you can't see the logout message. To verify this, use plain old hyperterminal on Windows to connect and then logout. If you see the message, then the connection was closed before the text could be displayed.

The echo 'logout' with trap 0 is something that was added to .profile back in the late 1980's when the network was a 2400 baud modem. trap 0 is typically used to close and remove temp files and other end-of-job tasks, and the item in .profile may have been only an example. For very fast computers with very fast networks and clients, there is certainly the possibility of a race condition. After all, text on a screen is a very slow event compared to the server and client speeds.


Bill Hassell, sysadmin
Laurent Menase
Honored Contributor

Re: trap "echo 'logout'" 0 in 11.31

Hi
you may try
in fact it is working at least on my 11.31 systems.
trap "echo logout; sleep 1" 0
Candace Pettit
Advisor

Re: trap "echo 'logout'" 0 in 11.31

Bingo Laurent! That was the issue. It was exiting the shell so quickly that it wasn't trapping the signal for shell exit. And it worked on our 11.00 system on much older hardware probably because it took a little longer on a shell exit, so it was able to trap the signal.

Oh, and just to answer you, Bill, our telet program stays open and usually has a Status line where it will indicate "Connected" or "Not Connected". But this can be disabled, so our users who had it disabled were not able to do if they were logged out or not. We have login limitations, so it is important that our users do not leave "ghost" login sessions, so their being able to see "logout" is very important to us.

Thank you all for your input. Now it's time to go edit .profiles :)