1752794 Members
6086 Online
108789 Solutions
New Discussion юеВ

Re: unable to get pty

 
SOLVED
Go to solution
Ahmed Zaher
Advisor

Re: unable to get pty


Dear Dennis,

Thanks for your patience.

This script was made to allow our NOC agents to open and monitor the Alarm Browser but the problem that they don't correctly close the XDMCP session or the session hangs then he open another one.

Could you please tell me how to modify the script using the mentioned signal trap and how to make it wait N seconds?

I don't konw what I should do.

Please help and many thanks again.
Dennis Handly
Acclaimed Contributor

Re: unable to get pty

>Could you please tell me how to modify the script using the mentioned signal trap and how to make it wait N seconds?

What's in xnmevents.sh now?

I assume you would add:

LOGFILE=/var/tmp/xnmevents.log
function catch_sighup {
echo "$0: SIGHUP $(date +'%Y%m%d.%H%M%S')" >> $LOGFILE
echo "$0: My PID: $$, parent $PPID" >> $LOGFILE
exit 1
}

And before you execute xnmevents:
trap catch_sighup HUP

This currently logs but doesn't kill its parent. After collecting the log for a few times, we can see where to go next.
Dennis Handly
Acclaimed Contributor

Re: unable to get pty

>ME: After collecting the log for a few times, we can see where to go next.

I tried it out, it seems to log SIGHUP.

You could try kill and if that fails, kill -9:
# kill dtexec parent to cleanup
kill $PPID
sleep 30
# See if dtexec died?
kill -0 $PPID
if [ $? -eq 0 ]; then # still there
kill -9 $PPID
fi
exit 1
Ahmed Zaher
Advisor

Re: unable to get pty


Dear Dennis,

Many Thanks for your interest.

But really I am new in Unix and I don't know where to put these commands in the script and how the script will know that the session was terminated in order to kill its process.

Attached is the script.

Kindly write this script to me and I will appreciate this effort.

Thanks in advance.
Dennis Handly
Acclaimed Contributor

Re: unable to get pty

See attached. Basically it is like this:
function catch_sighup {
# logging for SIGHUP
echo "$0: SIGHUP $(date +'%Y%m%d.%H%M%S')" >> $LOGFILE
echo "$0: My PID: $$, parent $PPID" >> $LOGFILE
exit 1 # Remove if you want to kill

# kill dtexec parent to cleanup
kill $PPID
sleep 30
# See if dtexec died?
kill -0 $PPID
if [ $? -eq 0 ]; then # still there
kill -9 $PPID
fi
exit 1
}

Let it run with just logging for a few times.
If you want it to kill, remove that first "exit 1".
If you don't want it to log, you can comment out those "echo"s.
Ahmed Zaher
Advisor

Re: unable to get pty


Dear Dennis,

What did you mean with the phrase (If you want it to kill, remove that first "exit 1".
)?

I should write this script one time and it will be executed automatically when the user login. Please clarify?
Dennis Handly
Acclaimed Contributor

Re: unable to get pty

>What did you mean with the phrase (If you want it to kill, remove that first "exit 1".)?

I have no idea if what I have will work. I don't know what the signal is. So we need to try it for awhile.

>I should write this script one time and it will be executed automatically when the user login.

That's the assumption.

I had another thought if you want to experiment.
You may want to replace what you have by:

/opt/OV/bin/xnmevents < /dev/null > /dev/null 2>&1 &

And try to bring it up. If it never shows up or just flashes, then that won't work. If it comes up, try having the user close the session incorrectly and see if it goes away.

(Or while it is up, look at that "UNIX95= ps -Hfu noc" to see if dtexec is even there anymore?