Logout automatically when exiting a script


 
Thread Tools Search this Thread
Operating Systems SCO Logout automatically when exiting a script
# 1  
Old 02-24-2015
Logout automatically when exiting a script

Hi,

I am using SCO Unix. I write a script to execute a program by calling

Code:
exec program

The script will check the program is still there or not, if not, then it will exit the script by calling

Code:
exit

So if I press DEL to quit the program, the script will exit, but it will logout also..... Is exit terminate the running script, but not the calling shell, right?

Do you know why??

Thanks!
Danny

Last edited by Don Cragun; 02-24-2015 at 06:21 AM.. Reason: Add CODE tags.
# 2  
Old 02-24-2015
The command exit does just that, exit the current process. If the current process is the login shell, then you get logged off. What you are doing by calling exec program is to say 'replace the current shell with program' so when the program ends, there is nothing to go back to.

What is your desired response?
  • CNTL-d ends program but does not log out (where do you go then)
  • Failure to find program logs out
  • Normal termination logs out
  • The complete opposite of any/all of these?
If you can be clear about what you want to happen, then we can probably work out a way to make it so.



Robin
# 3  
Old 02-24-2015
Hi, thanks for your suggestion!

May be I mis-interpret that exec is executing program in new shell.

What I want is DEL to stop the program, and the script exit, BUT don't logout. Is there any method?

Thanks!
Danny
# 4  
Old 02-24-2015
Run the program without using exec. When it completes, you will return to where you are.

I think that this is what you need. If you are getting a permission denied or a cannot execute message then that's something else to work on.



Robin
# 5  
Old 02-24-2015
Thanks!

I tried without exec, but it is the same, it still logout when exit.
# 6  
Old 02-24-2015
Please show us exactly what you are doing, word for word, letter for letter, keystroke for keystroke.
# 7  
Old 02-24-2015
Also what is in the user's .profile?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help for exiting the function not script

function2() { cmd1 cmd2 cmd3 .... cmdn } function2() { cmd11 cmd12 cmd13 .... .... } for i in {1,2} (7 Replies)
Discussion started by: yanglei_fage
7 Replies

2. Shell Programming and Scripting

Exiting from the script abruptly

Hi Team, Need your help for the below code snippet. I wrote a module to read the file names remote server using file name convention. Issue : My script is coming out from while loop without reading complete file. test1() { while read line do echo $line file_nm_convention=`echo... (3 Replies)
Discussion started by: gvkumar25
3 Replies

3. Shell Programming and Scripting

Exiting out of the script

I have to write a script in ksh which again should call another script. Say A.ksh is calling B.ksh. Now in B.ksh if the condition we are checking for is true then we have to go back to the main script A.ksh or if the condition in B.ksh is false then we have to totally come out of the scripts. I... (1 Reply)
Discussion started by: vpv0002
1 Replies

4. Shell Programming and Scripting

Bash Script Not Exiting

I have a script planned for the Helpdesk to allow them to (on a couple of RHEL 3 / RHEL 5 servers) reset passwords, stop / start printers, and clear print queues. The appropriate sudo permissions were given to their accounts, and the individual functions all work just fine. The ability to move... (0 Replies)
Discussion started by: tearsong
0 Replies

5. Shell Programming and Scripting

How to run script on logout ?

Hi Everybody, I want to run my own script on logout , i can use .bash_logout file... problem is this will work only for that particular user... i want to know the common file... so that script wil run for all the user... 2. How to run script on Shutdown ? Thanks in advance Anitha (4 Replies)
Discussion started by: anisn2002
4 Replies

6. Shell Programming and Scripting

exiting from script

Hi, I am trying to exit the script from a function. I was in assumption that if we use exit ( inside or outside the function) it will exit from the script. alternatively, return will exit from that particular function. but in my case, exit is exiting from the function and not the script.... (8 Replies)
Discussion started by: shellwell
8 Replies

7. Shell Programming and Scripting

Exiting a script

I have a script abc.sh. Its contents are as follows: (7 Replies)
Discussion started by: lassimanji
7 Replies

8. Shell Programming and Scripting

exiting from script

there are many script in my project.i am having a problem when i am trying to quit from child script.what is the command to wrap up all the parent script and calling script as well? exit 0 is not working.please help.... (1 Reply)
Discussion started by: arghya_owen
1 Replies

9. UNIX for Dummies Questions & Answers

Login and logout script

Hi all I know ho I can run a script when a user logs in, viz using the .login or .profile file, however what can I use to run a script when a user logouts ? Thanks J :confused: (1 Reply)
Discussion started by: jhansrod
1 Replies

10. UNIX for Dummies Questions & Answers

logout/shutdown script

I am running JDictd (http://www.informatik.uni-leipzig.de/~duc/Java/JDictd/) from tcsh in Terminal on Mac OS X (:=Darwin=FreeBSD/Mach). I am trying to get it to exit cleanly silently upon Mac OS X system shutdown. My idea was that if there was a logout script in FreeBSD (basically a script... (1 Reply)
Discussion started by: ropers
1 Replies
Login or Register to Ask a Question