AnsweredAssumed Answered

Can't locate Nimbus/API.pm

Question asked by itadminintel on Apr 2, 2015
Latest reply on Mar 6, 2016 by chrlu01

Hi, I have a perl custom probe but it din't start. I have installed active perl 64bit on c:\perl64 where have to run. I also deploy the sdk package to the robot, in the controller environment there is the variable PERL5LIB C:\Program Files (x86)\Nimsoft/perllib

If i try to start manually the probe I get the following error:

 

Can't locate Nimbus/API.pm in @INC (you may need to install the Nimbus::API module) (@INC contains: C:/Perl64/site/lib C:/Perl64/lib .) at C:\Program Files

(x86)\Nimsoft\probes\gateway\smsgtw\smsgtw.pl line 13.

BEGIN failed--compilation aborted at C:\Program Files (x86)\Nimsoft\probes\gateway\smsgtw\smsgtw.pl line 13.

 

what am I missing?

this is the script:

 

#!c:\Perl64\bin\perl
#############################################################
#
# Author: Ivan Pontiggia
#
# Scope: Send SMS from Nimbus through FoxBox LX800 gateway
#

use strict;
use GetOpt::Std;
use LWP::UserAgent;
require HTTP::Request;
use Nimbus::API;
use Nimbus::Session;
use Nimbus::CFG;

##############################################################
# Defaults and Initial values

my $prgname="smsgtw";
my $sess;
my $version="1.0";
my $config;
my $loglevel=4;
my $logfile="$prgname.log";
my $sms_logs;
my $sms_server="10.....";
my $sms_usr="admin";
my $sms_pass="......";
my $sms_tel="12334578";
my $sms_txt="Qui va il contenuto del messaggio";
my $sms_sender="Nimbus";

##############################################################
# Nimbus Support procedures

sub hubpost {
    my $hMsg = shift; # Msg Handle
    my $udata = shift; # User Data / Message
    my $full = shift; # Full Message

    my $subject = pdsGet_PCH($full,"subject");
    my $msgID = pdsGet_PCH($full,"ID");
    nimLog (1,"(hubpost) - request for SMS - subject: $subject, ID: $msgID");

    my $phone = pdsGet_PCH($udata,"phone");
    my $string = pdsGet_PCH($udata,"message");
    $string =~ s/\\//g;
    $string =~ s/\^//g;
    $string =~ s/\{//g;
    $string =~ s/\}//g;
    $string =~ s/\[//g;
    $string =~ s/\]//g;
    $string =~ s/\~//g;
    $string =~ s/\|//g;
    $string =~ s/\€//g;
    $string = substr($string, 0, 159);
    nimLog (1,"(hubpost) - phone: $phone, message: $string");

    send_sms ($phone,$string);
}

sub timeout {
    nimLog (3,"(timeout) - session terminated");
}

sub restart {
    nimLog (1, "(restart) - session restart");
    $config=Nimbus::CFG->new("$prgname.cfg");
    $loglevel=$options{d}||$config->{setup}->{loglevel}||0;
    $logfile=$options{l}||$config->{setup}->{logfile}||0;
    $sms_server=$config->{setup}->{sms_server};
    $sms_usr=$config->{setup}->{sms_usr};
    $sms_pass=$config->{setup}->{sms_pass};

    nimLogSet($logfile,$prgname,$loglevel,0);
}

#########################################
# SendSMS

sub send_sms {
    my $sms_phone = shift;
    my $sms_msg = shift;

    nimLog (1,"(send_sms) - phone: $sms_phone, message: $sms_msg");

    my $ua = LWP::UserAgent->new;
    my $url="http://$sms_server/source/send_sms.php?username=$sms_usr&pwd=$sms_pass&from=$sms_sender&nphone=$sms_phone&testo=$sms_msg";
    my $req = HTTP::Request->new(GET => $url);
    my $resp = $ua->request($req);
}

##############################################################
# Main
#   - verify command-line params
#   - load config file
#   - connect to Nimbus

getopts ("d:l:i:h");

if ( $opt_h ) {
    print "Usage: smsgtw -d <loglevel> -l <logfile> -i [-h ] \n";
    exit;
}

$config=Nimbus::CFG->new("$prgname.cfg");
$loglevel=$options{d}||$config->{setup}->{loglevel}||0;
$logfile=$options{l}||$config->{setup}->{logfile}||0;
$sms_server=$config->{setup}->{sms_server};
$sms_usr=$config->{setup}->{sms_usr};
$sms_pass=$config->{setup}->{sms_pass};


nimLogSet($logfile,$prgname,$loglevel,0);
nimlog(0,"---------------- Starting SMS Gateway (pid: $$) ----------------");

$sess = Nimbus::Session->new("$prgname");
$sess->setInfo($version,"Nimsoft Corporation for Aduno");
if ( $sess->attach("$prgname")) {
     nimlog(1,"no queue defined, using subscribe");
     if ( $sess->subscribe("SMS")) {
          nimlog(0,"failed to subscribe on default hub");
          exit;
     }
}

if ( $sess->server(NIMPORT_ANY, \&timeout, \&restart) == 0) {
    nimLog (1,"Server session created");
} else {
    nimLog (0,"Unable to create Server session");
}

$sess->dispatch();
nimLog(0,"STOP signal received... terminating");
nimLog(0,"Exiting program");
exit;

Outcomes