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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exit script

Status
Not open for further replies.

zoonkai

MIS
May 1, 2000
71
0
0
US
I'm trying to create a simple exit script. The applications being run by the end user are predominately CAPS Based. I would like to create a script call EXIT that exits out of unix

I have created executable scripts that contain (without quotations)

"exit"

and also

"exec exit"

neither one worked...

when i do "exit" or "exec exit" at the command prompt...it works fine.

Any help would be greatly appreciated.

Thanks Donald (Zoonkai) Dixon
donnan@don-nan.com
 
zoonkai,

'exec exit' and 'exit' will both work fine from the command line but will not work from within a script because when you call exit (or exec exit) from the script it exits the script, not the command line.

Try using the 'logout' command within your script.

Hope this helps. Regards,
Chuck

chuck.spilman@nokia.com
 
I'm getting the same failure this was as the other ways.

donnan # l EXIT
-rwxrwxrwx 1 root sys 7 Feb 5 10:49 EXIT
donnan # pwd
/zoonkai
donnan # /zoonkai/EXIT
/zoonkai/EXIT: logout: not found
donnan #
Donald (Zoonkai) Dixon
donnan@don-nan.com
 
can you just set up an alias in their .profile
alias EXIT=exit
so that EXIT and exit are the same command
 
same thing


$ pg .profile
:
# @(#) profile 23.3 91/10/24
#
# Copyright (C) 1989-1991 The Santa Cruz Operation, Inc.
# All Rights Reserved.
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
# .profile -- Commands executed by a login Bourne shell
#

PATH=$PATH:$HOME/bin:.:/usr/local # set command search path
MAIL=/usr/spool/mail/`logname` # mailbox location
export PATH MAIL

# Set terminal type
eval `tset -m ansi:ansi -m :\?${TERM:-ansi} -r -s -Q`
export TERM PATH SHELL HOME
[ -x /bin/termtype ] && /bin/termtype
/usr/bin/prwarn # issue a warning if password due to expire
mesg y
clear
news |pg
alias EXIT=exit

/usr/local/menu1

# DOUBLEVISION's preattachment call during login...
# /usr/lib/dv/preattach

$
$ EXIT
EXIT: not found
$
Donald (Zoonkai) Dixon
donnan@don-nan.com
 
Sorry, try this in the .profile
alias EXIT='exit'
you need to put single quotes around the system command
 
you can also create a script called EXIT and put one line in it
'exit'
single quotes around it
and make it executable
and that will work also
 
Still no luck....putting in profile gets
$ EXIT
EXIT: not found
$
****************************************************
creating command and running...just nothing happens

donnan # pg EXIT
'exit'
donnan # l EXIT
-rwxr-xr-x 1 root sys 7 Feb 5 13:14 EXIT
donnan # pwd
/bin
donnan # EXIT
donnan #
****************************************************

I'm assuming you were referring to the asterics on the same key as the quotation marks....but just in case, I tried the ones to the left of the "1" key....and no dice with that attempt either


Donald (Zoonkai) Dixon
donnan@don-nan.com
 
As far as I understand it alias is not available in bourne shell
man alias = ......

Limitations
===========

The versions of alias and unalias described here are available as built-in
commands in ksh(C).

There is no aliasing mechanism available in sh(C).

The alias and unalias commands built into csh(C) differ from those described
here.
__________________________________-

if you want them to be logged out after exiting the menu1 program you could just add the exit command as the last line of their .profile. this is not secure, since they can break out before the exit command is executed, but if you need security you can trap these signals. (ie trap 'continue' 0 1 2 3 15)

hth
unix42
 
None of what you've tried is going to work

What you need is a script that kills off the shell of its parent process.

Some shells make that easy- bash, for example sets PPID to the parent But you can do it yourself in .profile:

PPID=$$
export $PPID

Then your EXIT script (which must be somewhere in their PATH or they have to type ./EXIT) is just:


# EXIT script
kill -9 $PPID

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
In the .profile I put this


PPID=$$
export PPID <-----(no &quot;$&quot;)

and the script is like this..

donnan # pg EXIT
kill -9 $PPID
donnan #

This worked =)

is loging out by using the kill command going to cause any &quot;undetermined results&quot; over time or is it basically the same as logging out with the exit command?

Thanks!!


Donald (Zoonkai) Dixon
donnan@don-nan.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top