How can I exit from command prompt from shell file?
shell file contains :
if(); then
// some unix code here
else
// want to exit from cmd prompt or Kill current cmd prompt
fi
can any knows @ it?
How can I exit from command prompt from shell file? shell file contains :
can any knows @ it? |
||||
Like Chris Down, I'm going to assume that you are using GNU bash. Other shells may be different, but the general idea should be the same. In bash, the environment variable You can ask the user whether to exit using a construct like the following.
If it is available, you can use GNU
The numbers The |
||||
|
I assume that you mean you want to kill the interactive shell that the script was forked from. I also assume that that shell is If you are sourcing the script in that shell, just use
Or, in shells without
|
|||||
|
kill $PPID
? That will kill the parent process of your (script) process, because $PPID is the parent process ID. That said, this sounds like an awfully bad idea. At least I would not appreciate having my shell yanked out from under my feet, and even less so if I'm logged in e.g. through SSH to a remote host (perhaps having launched a few X applications through it, too). – Michael Kjörling Apr 18 at 6:21