![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script to manipulate a message count for the same IP @ diff session | gobinath | Shell Programming and Scripting | 1 | 05-28-2008 03:13 PM |
| tcsh + completing a sub-directory entry | JamesGoh | Shell Programming and Scripting | 0 | 04-23-2008 03:52 AM |
| Running a script without a terminal session | jjinno | Shell Programming and Scripting | 3 | 10-03-2007 01:50 AM |
| Completing ffmpeg installation | noamon | UNIX for Dummies Questions & Answers | 1 | 01-29-2007 11:14 AM |
| sqlplus session being able to see unix variables session within a script | 435 Gavea | Shell Programming and Scripting | 2 | 07-03-2006 10:11 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Terminate session on completing script
Hai all..
How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The exit command only takes me out of the scripting session. I want my telnet session to be killed (like what happens when i key in "exit" at the prompt). How do i do this. Aim is that the users who would be running this application through their handheld terminals should never have access to the unix prompt... Thanks in advance Deepu |
|
||||
|
The only way to do this would be to kill the parent pid of the java process from within the java code. And you still would not be guaranteed that the user did not get to the unix prompt.
Try: Unless you control the whole user environment, it may still be possible to get to the shell. Prolly your best bet is to create a captive user that logs in to a restricted shell, executes some type of .profile or .login script that ends with an "exit" to logout the process. trap as many signals as needed in that script. Make sure the .login or .profile is sourced. Here is a basic start Code:
trap "exit" 0 1 2 3 # whatever you need here # my .profile file for rksh # check for sourcing and exit if not Prog=".profile" if [ $(basename $0) = $Prog ]; then kill -9 $PPID exit 1 fi export PATH=".:/usr/bin" # whatever..... /path/to/my/javascript exit 0 |
|
||||
|
Reply to Jim : Termination of Session
Note: This is not a new thread. This is a continuation to my earlier post since i was not able to post this message as a reply. Sorry for any inconvenience....
Dear Jim Thanks for the solution. Its working for me indeed. I added the trap statement and the "exit 0" statement to my .profile. This seems to cut off the user from the unix prompt. Withing the application, all interrupts are handled thereby making sure that the user is not able to generate an interrupt and exit. Application always exits gracefully with an exit status of 3. I omitted the following lines from the sample script that you gave # check for sourcing and exit if not Prog=".profile" if [ $(basename $0) = $Prog ]; then kill -9 $PPID exit 1 fi Could you please explain to me what these lines does... Also you mentioned that this approach is not bulletproof.. Since it seems to be working fine for me now, i would like to know of situations where this approach fails.... Thanks and regards Deepu |
|
||||
|
What the block of code is: to make sure that the
.profile (or whatever) was started using the dot command, something like this: Code:
. .profile It's pretty hard to make something completely hack-proof. Example: periodically somebody discovers something like a buffer overflow in some call or another, which allows a user to enter kernel mode. They exploit it. If this is something regular users, ie., friendly users, are going to use it's probably okay. But if it's on a box sitting out outside a firewall, then the story is different. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|