Hi,<br><br>1. &quot;How can I determine what the user responds, is there errorlevels or anything like that?&quot;<br><br>You can check for the exit status of the xmessage command<br><br>2. &quot;What is the reason for doing &#39; &gt; /dev/null 2&gt;&amp;1&#39;&quot;<br>
<br>It redirects any standard out and standard error to oblivion<br><br>Let&#39;s say you have a vnc session on port 5902. You want a script that checks if there&#39;s a session and display a message to the user. And you want to know if the user read the message. Here&#39;s what you could do. (you&#39;ll have to adapt and add a loop in there if you have several vnc sessions)<br>
<br>Edit the linux user&#39;s ~/.vnc/xstartup and add an &quot;xhost +&quot; 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 &#39;{print $4}&#39; | awk -F &quot;:&quot; &#39;{print $2}&#39; &gt; log-ports<br><br>for user in `cat log-ports`<br>do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case $user in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5902)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; export DISPLAY=:2.0; xmessage -buttons &quot;I understand&quot;:10 -center -timeout 60 -file testmsg &gt; /dev/null 2&gt;&amp;1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ $? -eq 10 ] \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; echo &quot;$user acknowledged!&quot; \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || echo &quot;No answer from $user!&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; esac<br><br>done<br><br>The user connected to 5902 will get a windowed message with a &quot;I understand&quot; button. If he clicks on it, you&#39;ll know. If he doesn&#39;t, it&#39;ll time out after 60 seconds and return an exit status of 0 (zero): you&#39;ll know too .<br>
<br>Hope it helps,<br>Olivier<br><br><br><div><span class="gmail_quote">2008/1/31, Henning Larsen &lt;<a href="mailto:hennlar@start.no">hennlar@start.no</a>&gt;:</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>&gt; Hi,<br>&gt;<br>&gt; I would check for established VNC connections this way:<br>&gt;<br>&gt; netstat -tape | grep ESTABLISHED | grep Xvnc<br>
&gt;<br>&gt; As for warning connected users. If you see there is an established vnc<br>&gt; session on port 5902, you could simply do:<br>&gt;<br>&gt; export DISPLAY=:2.0; xmessage -center -timeout 60 -file shutdown.txt<br>
&gt; &gt; /dev/null 2&gt;&amp;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 &#39; &gt; /dev/null 2&gt;&amp;1&#39;<br><br>&gt; You could create a list of established connections, translate it to<br>
&gt; active displays (5902 -&gt; 2.0 | 5903 -&gt; 3.0 ...) and send out a<br>&gt; message.<br>&gt;<br>&gt; Hope it helps<br>&gt; Olivier<br>&gt;<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>