Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logout after executing script 1

Status
Not open for further replies.

mlazlo

MIS
Oct 3, 2001
27
US
I am attempting to execute a script, ./startrf.sh from the user's .profile.
What I need is to have the session execute and logout regardless of exit status. I have attempted to put this statement:
trap 'logout' 0 1 2 3 15
in both the .profile and ./startrf.sh
In either case this only works if the script exits cleanly. If they hit ^C then it jumps out of script and .profile without executing the trap and brings them to a command line.
I need this session to close.
Any ideas on how to make this happen?
Thanks in advance.
 
YOu can try using the "exec" command in .profile to call your script. The line following the exec command should be "exit
 
Thanks 'TheKidd' exec worked like a charm!
 
The exec works for telnet connections but not ssh. What is the solution for ssh.
 
Actually the exec command seems to work fine for me when I ssh into the server.
 
With ssh, changing 'logoff' to 'exit' in the code ending the script works with either:
exec scriptname
or
scriptname; exit
in the .profile

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top