1752574 Members
4949 Online
108788 Solutions
New Discussion юеВ

auto logout

 
SOLVED
Go to solution
HPquestion
Regular Advisor

auto logout

Hi there,
We are calling an X-windows based application from the .profile via reflection X automatically . Once the user exit out the application , I want to logoff the shell automatically as we don't want them to get the $ prompt at all.

Tried with kill -9 $$ and some thing like
shown below. Buit the $ prompt still remain.How to logout the users automatically after he/she is done with the application?

.profile code to execute the application.


cd /home/somestuff
./run_the_application
./kill_it
--------
kill_it has the following lines

#!/bin/ksh
MYUSER=`whoami`
for MYPID in `ps -ef | grep $MYUSER | awk '{ print $(2) }' | sort -r`
do
`kill -9 $MYPID`
done

46 REPLIES 46
Steven Schweda
Honored Contributor

Re: auto logout

How about something like this?:

cd /home/somestuff
exec ./run_the_application

"exec" causes "./run_the_application" to
replace the shell, so when it exits, the
process should die.

HP-UX-free example:

ALP $ rsh /user = root sol
Last login: Wed Feb 11 10:04:53 from alp-l.antinode.
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
You have new mail.
sol# pwd
/root
sol# exec pwd
/root

%RSH-S-REMCLOSED, Remote connection closed
ALP $
HPquestion
Regular Advisor

Re: auto logout

Thnaks! It dodn't work.

.profile with exec ./run_the_application
doesn't stopped opening/executing the application from xterm. Then
I have done the following.But its not existing out the $ prompt in the xterm.

.profile :
exec ./call_run

call_run has the following lines.
#!/usr/bin/ksh
exec ./run_the_application


HPquestion
Regular Advisor

Re: auto logout

sorry made some typos.I meant to say


.profile with exec ./run_the_application
stopped opening/executing the application itself from xterm. So I have done the following.But its not existing out the $ prompt in xterm.

.profile :
exec ./call_run

call_run has the following lines.
#!/usr/bin/ksh
exec ./run_the_application
Patrick Wallek
Honored Contributor

Re: auto logout

Just put an 'exit' after the './run_the_application' in the .profile.

When you exit the application, it will proceed to the next statement in the .profile file and exit out.

cd /home/somestuff
./run_the_application
exit
HPquestion
Regular Advisor

Re: auto logout

I tried the the exit earlier. If I put exit in the .profile, it doesn't open the application from Xterm at all.
Patrick Wallek
Honored Contributor

Re: auto logout

What kind of errors are you getting when it doesn't run?

The 'exit' after the 'run_the_application' should have no effect on the command, UNLESS you are doing a './run_the_application &', in which case the exit will kill the application when the shell exits.

Verify you are not trying to run the command in the background.
HPquestion
Regular Advisor

Re: auto logout

no error. It doesn't open the Xterm window at all if I put exit in the .profile
HPquestion
Regular Advisor

Re: auto logout

Thanks Parick. I am not running it in the background. If I put exit in .profile , xterm windown doesn't open at all
Steven Schweda
Honored Contributor

Re: auto logout

> [..] But its not existing out the $ prompt
> in the xterm.

What xterm? I think that you're hiding too
many details. Like who creates an xterm.

If you can provide a sample script which
really does something, then it might be
possible to suggest some changes. With no
information about who creates which process
how, running what, I'm lost.