DX Unified Infrastructure Management

 View Only
  • 1.  Can't locate Nimbus/API.pm

    Posted Apr 02, 2015 05:33 AM

    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;



  • 2.  Re: Can't locate Nimbus/API.pm

    Posted Apr 21, 2015 03:22 PM

    Try adding the following line to the top of the script itself...

     

    use lib 'C:\Program Files (x86)\Nimsoft\perllib';



  • 3.  Re: Can't locate Nimbus/API.pm

    Posted Feb 28, 2016 12:01 PM

    Hi ,

    I am having same issue. Were you able to resolve it? And how?

    thanks in advance



  • 4.  Re: Can't locate Nimbus/API.pm

    Posted Feb 29, 2016 05:28 AM

    1 - Once you install the package: SDK_Perl it will create: C:\Program Files (x86)\Nimsoft\perllib

    2 - If your perl is installed as: C:\strawberry64\perl\lib

    3 - copy the 3 subdirectories from 1 into the directory structure of: 2



  • 5.  Re: Can't locate Nimbus/API.pm

    Posted Mar 05, 2016 01:49 PM

    Hi Luc,

    Thanks. That helped. I copied 3 directories those where there in perllib folder to perl\site\lib folder, and that error was gone. Thank you.

     

    Right now I am struggling with error that came next as shown below. The dynaloder file and API.dll both exist in paths mentioned in error below. Any idea on this one? :

     

    Can't load 'C:/Perl64/site/lib/MSWin32-x64-multi-thread/auto/Nimbus/API/API.dll' for module Nimbus::API: load_file:The specified module could not be found at C:/Perl64/lib/DynaLoader.pm line 194. at getAlarms.pl line 6.

    Compilation failed in require at getAlarms.pl line 6.

    BEGIN failed--compilation aborted at getAlarms.pl line 6.

     

    Thanks,

    Sandeep



  • 6.  Re: Can't locate Nimbus/API.pm

    Posted Mar 06, 2016 03:13 AM

    Hi Sandeep,

    Did you install a Perl version 5.14.x? The sdk only supports those Perl versions.

    ( I used Activestate: ActivePerl-5.14.2.1402-MSWin32-x64-295342 and Strawberry: strawberry_5.14.2.1-64bit without problems)

    Regards, Luc



  • 7.  Re: Can't locate Nimbus/API.pm
    Best Answer

    Posted Mar 06, 2016 11:14 PM

    Hi Luc,

    Hats off.. You are an expert. Downloaded strawberry perl 5.14 version and it worked.

    Thank you very much