Hi,<br><br>1. "How can I determine what the user responds, is there errorlevels or anything like that?"<br><br>You can check for the exit status of the xmessage command<br><br>2. "What is the reason for doing ' > /dev/null 2>&1'"<br>
<br>It redirects any standard out and standard error to oblivion<br><br>Let's say you have a vnc session on port 5902. You want a script that checks if there's a session and display a message to the user. And you want to know if the user read the message. Here's what you could do. (you'll have to adapt and add a loop in there if you have several vnc sessions)<br>
<br>Edit the linux user's ~/.vnc/xstartup and add an "xhost +" in it. Otherwise you will not be able to display the message.<br><br>Use a script similar to this one: (of course, you will adapt and enhance)<br>
<br>#!/usr/bin/env bash<br><br>netstat -tape | grep ESTABLISHED | grep Xvnc | awk '{print $4}' | awk -F ":" '{print $2}' > log-ports<br><br>for user in `cat log-ports`<br>do<br>        case $user in<br>
                5902)<br>                        export DISPLAY=:2.0; xmessage -buttons "I understand":10 -center -timeout 60 -file testmsg > /dev/null 2>&1<br>                        [ $? -eq 10 ] \<br>
                            && echo "$user acknowledged!" \<br>                            || echo "No answer from $user!"<br>                        ;;<br>        esac<br><br>done<br><br>The user connected to 5902 will get a windowed message with a "I understand" button. If he clicks on it, you'll know. If he doesn't, it'll time out after 60 seconds and return an exit status of 0 (zero): you'll know too .<br>
<br>Hope it helps,<br>Olivier<br><br><br><div><span class="gmail_quote">2008/1/31, Henning Larsen <<a href="mailto:hennlar@start.no">hennlar@start.no</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for the good answer.<br><br>On Thu, 2008-01-31 at 15:05 +0100, Olivier Robert wrote:<br>> Hi,<br>><br>> I would check for established VNC connections this way:<br>><br>> netstat -tape | grep ESTABLISHED | grep Xvnc<br>
><br>> As for warning connected users. If you see there is an established vnc<br>> session on port 5902, you could simply do:<br>><br>> export DISPLAY=:2.0; xmessage -center -timeout 60 -file shutdown.txt<br>
> > /dev/null 2>&1<br><br>How can I determine what the user responds, is there errorlevels or<br>anything like that? Hundred years ago I was making a lot of advanced<br>BAT-files in msdos, but have not done much of those things in Linux yet.<br>
I could or maybe should find out reading man-pages, but have already<br>asked. :)<br><br>What is the reason for doing ' > /dev/null 2>&1'<br><br>> You could create a list of established connections, translate it to<br>
> active displays (5902 -> 2.0 | 5903 -> 3.0 ...) and send out a<br>> message.<br>><br>> Hope it helps<br>> Olivier<br>><br>It helps a lot, Thanks<br><br>Henning Larsen<br><br><br><br>--<br>fedora-list mailing list<br>
<a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>To unsubscribe: <a href="https://www.redhat.com/mailman/listinfo/fedora-list">https://www.redhat.com/mailman/listinfo/fedora-list</a><br></blockquote></div>
<br>