[Nut-upsuser] some help in using the package NUT in a perl script

Llabres Thill 21207261 at etu.unicaen.fr
Wed Feb 27 11:27:54 UTC 2013


 

Hello, 

I want use the package NUT in a script perl, i wonder how
use the result of method such as BattPercent() for example. 

here is my
code : 

_#!/usr/bin/perl -w_
_# server_

_use strict;_
_#use
/etc/nut/dev/modules;_
_#use IO::Socket::Multicast;_
_use
UPS::Nut;_

_my $message = localtime;_
_$message .=" `who` . n";_
_print
"-- test : $message n";_

_my $ups = new UPS::Nut(_
_ NAME => "UPS",_
_
HOST => "localhost",_
_ PORT => 3493,_
_ USERNAME => "upsmon",_
_
PASSWORD => "pass",_
_ TIMEOUT => 30,_
_ DEBUG => 1,_
_ DEBUGOUT =>
"/etc/nut/dev/log/nut.log"_
_);_

_if ($ups->Status() =~ /OL/) _
_ {_
_
print "UPS : Alimentation OK !n";_
_ }_
_if ($ups->Status() =~ /OB/) _
_
{_
_ print "UPS : PB alimentation, Fonctionne sur batterie !n";_
_
}_
_print " UPS ETAT : $ups->Status() n";_
_print " UPS charge batterie
: $ups->BattPercent() n";_
_print " UPS liste : $ups->ListVar()
n";_
_exit(0);_

Bu i got : something like :
"UPS::Nut=HASH(0x8505ad0)->BattPercent()" instead of the value
expected... 

Could somebody help me ? Thanks for all. 
--


Cordialement, 
Thill Llabrés - THILL.LLABRES at ETU.UNICAEN.FR
M2
E-Secure
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20130227/99699fde/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smiley-frown.gif
Type: image/gif
Size: 340 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20130227/99699fde/attachment.gif>


More information about the Nut-upsuser mailing list