Perl from TCL

Clovertech Forums Read Only Archives Cloverleaf Tcl Library Perl from TCL

Viewing 12 reply threads
  • Author
    Replies
    • #72480

      Could you please post your tcl code that exec’s the perl script?

      -- Max Drown (Infor)

    • #72481
      LaToya Butler
      Participant

        It’s very basic right now.  I just wanted to see if I could execute the program.

        # ‘run’ mode always has a MSGID; fetch and process it

        keylget args MSGID mh

        set msg [msgget $mh]

        set null {}

        set nursing_unit [getField “$msg” “PV1.3.0”]

        set room [getField “$msg” “PV1.3.1”]

        echo “HCISITEDIR=>$HciSiteDir<"

        set test_dir “$HciSiteDir/data/perl_code”

        echo ” TEST DIRECTORY IS ” $test_dir

        cd $test_dir

        exec /usr/bin/perl xtend.pl 5499 “TESTING FROM CLOVERLEAF “

        lappend dispList “CONTINUE $mh”

      • #72482

        Try just exec’ing perl (no path). A version of perl comes installed with Cloverleaf.

        Code:

        exec perl xtend.pl 5499 “TESTING FROM CLOVERLEAF “

        -- Max Drown (Infor)

      • #72483
        LaToya Butler
        Participant

          When I run that command, I get this error:  

          Can’t locate LWP/Simple.pm in @INC (@INC contains: /opt/quovadx/qdx5.7/integrator/lib/perl5/5.8.8/aix /opt/quovadx/qdx5.7/integrator

          /lib/perl5/5.8.8/aix /opt/quovadx/qdx5.7/integrator/lib/perl5/5.8.8 /opt/quovadx/qdx5.7/integrator/lib/perl5/site_perl/5.8.8/aix /op

          t/quovadx/qdx5.7/integrator/lib/perl5/site_perl/5.8.8/aix /opt/quovadx/qdx5.7/integrator/lib/perl5/site_perl/5.8.8 /opt/quovadx/qdx5

          .7/integrator/lib/perl5/site_perl/5.8.8/aix /opt/quovadx/qdx5.7/integrator/lib/perl5/site_perl/5.8.8 /opt/quovadx/qdx5.7/integrator/

          lib/perl5/site_perl . /work/quovadx_dev/qdx5.7P/integrator/lib/perl5/5.8.8/aix /work/quovadx_dev/qdx5.7P/integrator/lib/perl5/5.8.8

          /work/quovadx_dev/qdx5.7P/integrator/lib/perl5/site_perl/5.8.8/aix /work/quovadx_dev/qdx5.7P/integrator/lib/perl5/site_perl/5.8.8 /w

          ork/quovadx_dev/qdx5.7P/integrator/lib/perl5/site_perl .)

          I think it’s because the Cloverleaf version is older than the Unix version.

        • #72484

          Can you post your perl code? Tip: wrap it in the code tags on the forum to preserve formatting.

          -- Max Drown (Infor)

        • #72485
          LaToya Butler
          Participant

            Here’s the perl script.

            Code:


            #!/usr/bin/perl

            use strict;
            use LWP::Simple;
            use LWP::UserAgent;

            if ( $#ARGV != 1 ) {
              print “usage: perl xtend.pl [pager#] [message]n”;
            #   exit;
            }

            my $browser = LWP::UserAgent->new;

            my $pager = $ARGV[0];
            die “Invalid pager #: $pagern” unless $pager =~ /[0-9]{4}/;
            my $message = trim($ARGV[1]);
            die “Message is empty!n” unless $message;

            print “Paging $pager thru Xtend …n”;

            my $xtendURL = ‘http://test.edu;
            my $query = ‘/test’;

            my $response = $browser->get(”$xtendURL$query”);

            my $content = $response->content; #get “$xtendURL$query”;
            die “Couldn’t get $xtendURL” unless defined $content;

            # parse the content to get session ID

            if ( $content =~ m{new;

              my $response = $browser->post( “$xtendURL$1”,
                [ ‘cPageId’ => $pager,
                  ‘stdMsgs’ => ‘ ‘,
                  ‘cPageMsgQa’ => $message
                ]
              );
              die “$xtendURL error: “, $response->status_line unless $response->is_success;
              die “Invalid content type at $xtendURL — “, $response->content_type
               unless $response->content_type eq ‘text/html’;

            #   print $response->content;

              # parse output from xtend
              if ( $response->content =~ m{sialo[0-9].gif align=center border=0 >(.+)} ) {
               
                my $reply = $1;

                if ( $reply =~ m{Your page is being sent to ([w, ]+)} ) {
                   print “sent to: $1n”;
                }  
                else {
                   print “result: $replyn”;
                }
              }

            } else {
              print “Couldn’t find the match-stringn”;
            }

            sub trim($) {
              my $string = shift;
              $string =~ s/^s+//;
              $string =~ s/s+$//;
              return $string;
            }  

          • #72486
            Joe Halbrook
            Participant

              It looks like the LWP::Simple Perl module is not installed.  I’d have your OS folks install that mod, and retry.

            • #72487

              Just to add to what Joe said, the module needs to be installed in the Cloverleaf perl installation.

              -- Max Drown (Infor)

            • #72488
              LaToya Butler
              Participant

                He installed it on the server level.  Can he use this exact package for the Cloverleaf level?

              • #72489

                Yes, I believe so.

                -- Max Drown (Infor)

              • #72490

                You may also consider writing that script in tcl.

                -- Max Drown (Infor)

              • #72491
                Charlie Bursell
                Participant

                  I am assuming this on Unix.

                  Change the first line of your perl script to : #!/bin/env perl

                  Make sure you script is your path.  A good ides is to put it in $HCISITEDIR/scripts.  MAke sure it is executable 775

                  Should work

                • #72492
                  David Barr
                  Participant

                    If you are trying to call a Perl script using a copy of Perl that isn’t included with Clovlerleaf (like /usr/bin/perl), you also need to make sure that you unset the PERL5LIB environmental variable before you call your script.  If you don’t then your script will be using only the modules that are included with Cloverleaf.

                Viewing 12 reply threads
                • The forum ‘Tcl Library’ is closed to new topics and replies.