From: Vahis on
I found notify-send to be very much what I've been looking for:
http://en.opensuse.org/OpenSUSE_Weekly_News/120#nixCraft.2FVivek_Gite:_10_Tools_To_Add_Some_Spice_To_Your_UNIX_Shell_Scripts

and from there:
http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html

The first item there is
#1: notify-send Command

I find this very useful in maintaining a friend's machine.

Now if I connect over ssh it doesn't work out-of-the-box.
It needs the display information.

So I first connect and then run (in one line):

export DISPLAY=:0 && export XAUTHORITY=~/.Xauthority && notify-send "The
message you want to pop up"

I've made a script that does this display thing and sends the message.
(I place this script on the remote machine)
-------------------------------------------------------------
#!/bin/bash
# script to send a message with notify-send
# the variable -t 0 at the end makes the message stay until clicked

export DISPLAY=:0 && export XAUTHORITY=~/.Xauthority && notify-send \
"I'll install some updates, don't shut down" -t 0

----------------------------------------------------------------

It would be convenient to get first OK from the user.
Is there a way to have the script to return OK when the user has clicked
the message?


Vahis
--
http://waxborg.servepics.com
openSUSE 11.2 (x86_64) 2.6.31.12-0.2-default
12:50pm up 30 days 16:08, 17 users, load average: 4.05, 4.06, 4.09
From: Vahis on
On 2010-04-25, houghi <houghi(a)houghi.org.invalid> wrote:
> Vahis wrote:
>> It would be convenient to get first OK from the user.
>> Is there a way to have the script to return OK when the user has clicked
>> the message?
>
> That would depend on notify-send and from what I can see, that is not
> possible.

I think so, too.

> If you want feedback, you better use zenity or kdialog.
> However that will leave the script running untill it is clicked.

My idea is the following:
When I happen to remember I ping the machine and if it's on I send the
question if it's OK to install stuff.

Now all I want is the user's attention to make sure the machine
won't be shut down in the middle of everything. So I would like to know
if the message has been seen.

(Yes, I know, we have phones here, too, but it's not very geekish to
call to ask)

I could make a script with kdialod that would send a message back.
But that would require ssh credentials for the user AFAIK?

A restricted user in my end who can only send a message to me? Hmmm...

That is I don't want the script to do anything else, just reply.

I want to run the updates myself and whatever stuff I like.
Like today I installed LXDE on that machine, hoping it would become
more responsive.

I then sent "Call me back, we need to test new stuff.
Now I'm just waiting.

>I will asume he will be following orders. That would mean he will be
> annoyed to be clicking on OK each time AND the script will halt, unless
> it is clicked.

She is cool with one ok I guess. That's all I need to proceed.

Vahis
--
http://waxborg.servepics.com
openSUSE 11.2 (x86_64) 2.6.31.12-0.2-default
16:09pm up 30 days 19:27, 14 users, load average: 4.05, 4.08, 4.09
From: Vahis on
On 2010-04-25, houghi <houghi(a)houghi.org.invalid> wrote:
> Vahis wrote:
>> My idea is the following:
>> When I happen to remember I ping the machine and if it's on I send the
>> question if it's OK to install stuff.
>
> Brrr. The dreaded ping. ;-)
> Why not just start the ssh. If it answers, it works, if not then it
> won't. No need to ping.

You obviously dislike ping?
I found it necessary this morning:
The machine replied to ping but there was nothing behind ssh.

I had run the updates yesterday. Since there had been a few weeks in between
there was also the new kernel. So I just rebooted the machine but I
never tried to connect again before this morning.

Today I couldn't get in anymore. I pinged and got a reply, so the
machine was up.

Somehow the settings had been updated in such a way that the firewall
stopped ssh. A good ol'telephone was needed.

During the telephone conversation I guided the user to start yast and to
stop the firewall. Some job. It sounded like the user interface in the
other end could have been just as well in Chinese.

I wish I won't have to do anything this way again.

So ping didn't fix it but with the aid of it I knew the machine was up.
>
>> Now all I want is the user's attention.
>
> So you ssh, enter and send the message.

That's where I'd like feedback if it's been noted.
>
> You run kdialog on the remote machine. If there is the apropriate
> response you do what is needed.

>> I want to run the updates myself and whatever stuff I like.
>
> Why not do the updates with zypper on an automated basis.

The machine is very low spec and connected via umtsmodem.
So the user does not need updates in the middle of her firefox session.
The user can't leave it running overnight either because of its noise.

Still the kernel updates require user intervention, I would not like to
do them automagically over there before seeing that the new kernel (and
everything else) work for me here.
>
>> I then sent "Call me back, we need to test new stuff.
>> Now I'm just waiting.
>
> I though calling was not geek enough? ;-)

I didn't know any better way for testing GUI and getting user response.
>
> So you ssh into the machine, run the script and see what the feedback
> is.
>
> #v+
> #!/bin/bash
> export DISPLAY=:0
> export XAUTHORITY=~/.Xauthority
> kdialog --warningcontinuecancel "Press continue to install the
> updates\nDo not shut down!"
> SELECT=$?
> case $SELECT in
> 0) echo "Continue";;
> 1) echo "No";;
> 2) echo "Cancel";;
> esac
> #v-
>
> If you see "Contuinue" you continue, else you don't. Whether you do that
> automagically or not is up to you.

That could do it, I'll try it in a moment :)

Vahis
--
http://waxborg.servepics.com
openSUSE 11.2 (x86_64) 2.6.31.12-0.2-default
18:29pm up 30 days 21:47, 13 users, load average: 4.14, 4.11, 4.09
From: Vahis on
On 2010-04-25, houghi <houghi(a)houghi.org.invalid> wrote:
> Vahis wrote:

>> Now all I want is the user's attention to make sure the machine
>> won't be shut down in the middle of everything. So I would like to know
>> if the message has been seen.
>
> So you ssh, enter and send the message.
> You run kdialog on the remote machine. If there is the apropriate
> response you do what is needed.

>> Like today I installed LXDE on that machine, hoping it would become
>> more responsive.
>>
> So you ssh into the machine, run the script and see what the feedback
> is.
>
> #v+
> #!/bin/bash
> export DISPLAY=:0
> export XAUTHORITY=~/.Xauthority
> kdialog --warningcontinuecancel "Press continue to install the
> updates\nDo not shut down!"
> SELECT=$?
> case $SELECT in
> 0) echo "Continue";;
> 1) echo "No";;
> 2) echo "Cancel";;
> esac
> #v-
>
> If you see "Contuinue" you continue, else you don't. Whether you do that
> automagically or not is up to you.

I tried that in my LAN here. Works perfectly.

But:
Unfortunately I had just installed LXDE on the remote machine, it is now
running, and, of course kdialog does not work :(

Now I need something not-kde.

Vahis
--
http://waxborg.servepics.com
openSUSE 11.2 (x86_64) 2.6.31.12-0.2-default
20:11pm up 30 days 23:29, 12 users, load average: 4.16, 4.06, 4.04
From: Vahis on
On 2010-04-25, houghi <houghi(a)houghi.org.invalid> wrote:
> Vahis wrote:
>> But:
>> Unfortunately I had just installed LXDE on the remote machine, it is now
>> running, and, of course kdialog does not work :(
>>
>> Now I need something not-kde.
>
> zenity. That is GNOME and might lean more to LXDE. As a last resort, you
> could install tk and write something in wish.
> http://pages.cpsc.ucalgary.ca/~saul/personal/archives/Tcl-Tk_stuff/tcl_examples/
> However that is a completely different language again.
>
> I would go for zenity or kdialog. These can be installed without KDE and
> GNOME although some libraries will be added.
>
I typed zenity in YaST search window and saw yad.
It looked good:

"yad - A fork of Zenity with many improvements"

I like the yet another stuff somehow :)
So I went http://code.google.com/p/yad/wiki/Examples

A nice Yes/no sample there:
--text "Microsoft Windows has been found! Would you like to remove it?"

Let's see if yad will do it.

Vahis
--
http://waxborg.servepics.com
openSUSE 11.2 (x86_64) 2.6.31.12-0.2-default
05:52am up 31 days 9:10, 14 users, load average: 4.09, 4.38, 4.67