Results 1 to 5 of 5
I'm working on my final project (due tomorrow) and I have ONE LINE I haven't been able to figure out.
We have to write a script that gives the user ...
- 07-04-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 2
Bash script - command line to terminate session
I'm working on my final project (due tomorrow) and I have ONE LINE I haven't been able to figure out.
We have to write a script that gives the user a menu with options to list current directory, show path of current directory, see who's logged on, etc. Easy stuff. But the last menu option is "Exit from UNIX" and I've been going through my textbooks and googling and I can't figure out how to completely exit from within the script. "Exit" just gets me out of the script and back to the command prompt. I tried inserting an EOF but that did nothing.
Please help!
Thanks,
Katie
- 07-04-2009 #2Just Joined!
- Join Date
- Jun 2009
- Posts
- 44
I think exit should work (in lowercase letters).
Or maybe something like kill could be used.
Third option: Wait for some more replies...
- 07-04-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You could try the logout command. It's a shell command, however; it might not work for you. Effectively, it terminates a login shell, so if your menu is inside a shell script, it might work.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-04-2009 #4
- 07-04-2009 #5Just Joined!
- Join Date
- Jul 2009
- Posts
- 2
Kill worked! Thanks ADFC!
I used:
pid=$(ps x | grep 'Ss' | cut -d ' ' -f 2)
pid2=$(echo $pid | cut -d ' ' -f 1)
kill -9 $pid2
Thank you thank you thank you.
Katie


Reply With Quote
