Logout automatically when exiting a script

Hi,

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

exec program

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

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

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

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

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

Thanks!

I tried without exec, but it is the same, it still logout when exit.

Please show us exactly what you are doing, word for word, letter for letter, keystroke for keystroke.

Also what is in the user's .profile?