Operating System - HP-UX
1855622 Members
10138 Online
104112 Solutions
New Discussion

Re: Sending logout for a user fro a script shell

 
SOLVED
Go to solution
Sirius Black
Regular Advisor

Sending logout for a user fro a script shell

Hi all,
I've to do a shell script which run an application and after having done it will logout the user .
I run this script in .profile of user an currently I succeed in doing it by this command:
kill -9 `who -mu | awk '{print $7}'`.
But I don't want to use the kill command.
Any suggestion?
Thanks
Fabrizio
10 REPLIES 10
Jeff Schussele
Honored Contributor

Re: Sending logout for a user fro a script shell

Hi Fabrizio,

Have you tried the exit command?

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sirius Black
Regular Advisor

Re: Sending logout for a user fro a script shell

If I use the exit command in shell script, the user will be not logged out from the machine but only from the shell script.
Thanks
Marc Smith
Occasional Advisor
Solution

Re: Sending logout for a user fro a script shell

Use the command "exec" to execute your script in the .profile.
Sundar_7
Honored Contributor

Re: Sending logout for a user fro a script shell

If all that user allowed to do is to run the application then you can also try to change the login shell of the user to reflect the application.

This way once the user is done with the application, he will be logged out.
Learn What to do ,How to do and more importantly When to do ?
RAC_1
Honored Contributor

Re: Sending logout for a user fro a script shell

The code will look something like this. .profile of the user.

usual stuuff.
application to execute
exit

This should do what you want

Anil
There is no substitute to HARDWORK
Sundar_7
Honored Contributor

Re: Sending logout for a user fro a script shell

If your application is say /opt/app/app2/binary then

# usermod -s /opt/app/app2/binary username

Now whenever the user logs in your application gets executed and when he exits out of the application, the user is logged out of the system.
Learn What to do ,How to do and more importantly When to do ?
Sirius Black
Regular Advisor

Re: Sending logout for a user fro a script shell

Yes I can put it as the start program the only one problem is that the script receive some parameters and when I tried to put this parameters in the startup program, but it doesn't accept this parameters.
Hi all
Fabrizio
RAC_1
Honored Contributor

Re: Sending logout for a user fro a script shell

Did you export the parameter, so that it becomes available to program??

export SAM=123

Anil
There is no substitute to HARDWORK
Sirius Black
Regular Advisor

Re: Sending logout for a user fro a script shell

Hi Marc Smith ,
the exec before the command it's the best way but how this command works ?
Thanks Fabrizio
Marc Smith
Occasional Advisor

Re: Sending logout for a user fro a script shell

You should just put at the end of the .profile this:

exec <script_name>