Operating System - Linux
1752630 Members
5852 Online
108788 Solutions
New Discussion юеВ

Re: New mail triggering a script to turn off computer

 
Sujith Reddy
New Member

New mail triggering a script to turn off computer

Hello,

I am working in a linux lab at OSU. We have a UPS that sends a mail(gmail or any) if there is any power cut. I would like the workstation to execute shutdown script when this mail is dispatched by the UPS. Can any one help me out?
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: New mail triggering a script to turn off computer

> [...] the workstation [...]

Not a very detailed description of anything.

sizer -v

(Unless you're lost, in which case:
uname -a
might be more informative.)

Generally, I'd start with:
man forward
and look for "|". It might be reasonable to
create a special user name (alias) for this
kind of e-mail.

man aliases

I've never tried to run "shutdown" this way,
so there may be complications in dealing with
it (or any other, similarly privileged
program) from a "forward" environment. Some
experimentation may be required.
Sujith Reddy
New Member

Re: New mail triggering a script to turn off computer

We have an event trigger in Microsoft Outlook, the property by which we can start any application or scripts etc, on receiving an email (A notification type). I wanted to use that logic in linux to shutdown the system upon an email. This email is sent by an uninterruptible power supply in case of power failure. A code checking user mails from sendmail and executing script will also work for me. If you still did not get the point, could you please let me know what to explain?

Thanks,
Sujith
Steven Schweda
Honored Contributor

Re: New mail triggering a script to turn off computer

> [...] linux [...]

You're asking this in a Tru64 UNIX forum, not
in a Linux forum. (What led you here?)


> [...] what to explain?

> sizer -v

> uname -a

First, I was hoping that you'd run those
commands, and post their output, so that I
might not need to guess the kind of system
you're asking about. If it really is some
kind of Linux, then you might reveal which
Linux distribution you're using.

> man forward
> and look for "|".

Did you try that? If you're running
something other than sendmail on a Tru64
system, then you may need to look somewhere
else to learn how to get your particular mail
delivery program to run a script, but my
psychic powers are too weak to be of much use
in this case.

Pieter 't Hart
Honored Contributor

Re: New mail triggering a script to turn off computer

apart from remarks from Steven,

why do you need to act on an e-mail?
is this workstation so far away from the PSU?

most PSU's supply a physical connection (often DB9 connector) to signal the connected devices of a power failure.
and they supply software too that will initiate the shutdown action.
Matti_Kurkela
Honored Contributor

Re: New mail triggering a script to turn off computer

If the UPS is not also powering the mail server and all the network hardware required for the UPS to connect to the mail server, the mail notification won't be reliable.

Outlook events have a problem that some of them are only executed while Outlook is running, and normally nobody will think twice about closing an email program.

But if the UPS can send email, that indicates it has network connectivity. It probably can do other network protocols too, and those protocols might be more suitable for constant monitoring. For example, if the UPS supports Simple Network Management Protocol (SNMP), the snmp-ups driver of the NUT UPS monitoring suite might work with it.

See: http://www.networkupstools.org

The NUT suite is included in many Linux distributions, so if you're using Linux, you can probably install it using your distribution's package management tools, and your Linux distribution may even include some specific documentation about configuring it. If you cannot find any distribution-specific documentation, use the documentation on the www.networkupstools.org website.

The NUT suite supports many UPS hardware vendors and many Unix-style operating systems. There are even NUT clients for Windows.

MK
MK