Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like my backup script to issue a notification once it's done. I run Ubuntu as a headless server and login into it using PuTTY on Windows. I've already installed x11-apps and verified xclock and xcalc to run successfully on the Windows X server (Xming).

If this is not possible, which notification system can I use instead?

share|improve this question

2 Answers 2

If your server is 'truly' headless - as it will be when you installed a server edition of Ubuntu - then it will not have the X libraries installed and therefore will not be able to act as an X client, so there is no way for it to control the X server on Windows. (Note that not even xterm will be installed.)

If your PuTTY session is still open, then the server could use wall to make a notification appear on all terminals.

Otherwise, the customary (and resilient) way to notify the administrator is to send e-mail. If you use cron to trigger the backup job, you don't even need to do anything for that. I'm a bit out of touch with Windows, but I guess you can make Windows notify you when a specific email comes in.

share|improve this answer
    
Thanks for the explanation. Actually, I've installed x11-apps and am able to run xclock and xcalc successfully on the Windows X server (Xming). Given this, would it now be possible to use notify-send to issue a pop-up notification on my Windows PC? –  silvernightstar Oct 6 '13 at 21:21
    
In theory, yes. In practice it will depend on the capabilities of the X server. Why don't you try it out? –  zwets Oct 6 '13 at 21:32

I've managed to do this with growl for windows. Here's something that should get you started real quick:

  • Install growl for windows
  • On the 'security' tab of the growl configuration, disable the 'require password for LAN apps'(YMMV, I manage security using windows firewall) and enable 'Allow network notifications'

The above will enable a notification server on windows(add growl for windows to the startup applications so you always have it running)

There are many ways to send notifications from your ubuntu server, heres a simple way with python: - Install python/virtualenv - Install gntp package: $ pip install gntp

Now open a text editor and paste the following:

#!/usr/bin/env python
import gntp.notifier


def send(description, applicationName='Sample Application', noteType="Message",
    title="Msg", applicationIcon=None, hostname='127.0.0.1',
    password=None, port=23053, sticky=False, priority=None,
    callback=None, notificationIcon=None, identifier=None):

    growl = gntp.notifier.GrowlNotifier(
        applicationName=applicationName,
        notifications=[noteType],
        defaultNotifications=[noteType],
        applicationIcon=applicationIcon,
        hostname=hostname,
        password=password,
        port=port,
        )

    result = growl.register()

    return growl.notify(
        noteType=noteType,
        title=title,
        description=description,
        icon=notificationIcon,
        sticky=sticky,
        priority=priority,
        callback=callback,
        identifier=identifier,
        )


if __name__ == '__main__':
    send('Testing sample application')

This assumes that your ssh client is forwarding port 23053 to your windows machine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.