Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Tcl Library › Perl from TCL
- This topic has 13 replies, 5 voices, and was last updated 14 years, 1 month ago by David Barr.
-
CreatorTopic
-
August 27, 2010 at 1:55 pm #51957LaToya ButlerParticipant
I -
CreatorTopic
-
AuthorReplies
-
-
August 27, 2010 at 2:56 pm #72480Max Drown (Infor)Keymaster
Could you please post your tcl code that exec’s the perl script?
-- Max Drown (Infor)
-
August 27, 2010 at 3:06 pm #72481LaToya ButlerParticipant
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”
-
August 27, 2010 at 3:10 pm #72482Max Drown (Infor)Keymaster
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)
-
August 27, 2010 at 3:12 pm #72483LaToya ButlerParticipant
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.
-
August 27, 2010 at 3:14 pm #72484Max Drown (Infor)Keymaster
Can you post your perl code? Tip: wrap it in the code tags on the forum to preserve formatting.
-- Max Drown (Infor)
-
August 27, 2010 at 3:19 pm #72485LaToya ButlerParticipant
Here’s the perl script.
Code:
#!/usr/bin/perluse 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;
} -
August 27, 2010 at 3:22 pm #72486Joe HalbrookParticipant
It looks like the LWP::Simple Perl module is not installed. I’d have your OS folks install that mod, and retry.
-
August 27, 2010 at 3:24 pm #72487Max Drown (Infor)Keymaster
Just to add to what Joe said, the module needs to be installed in the Cloverleaf perl installation.
-- Max Drown (Infor)
-
August 27, 2010 at 3:26 pm #72488LaToya ButlerParticipant
He installed it on the server level. Can he use this exact package for the Cloverleaf level?
-
August 27, 2010 at 3:27 pm #72489Max Drown (Infor)Keymaster
Yes, I believe so.
-- Max Drown (Infor)
-
August 27, 2010 at 3:28 pm #72490Max Drown (Infor)Keymaster
You may also consider writing that script in tcl.
-- Max Drown (Infor)
-
August 27, 2010 at 3:53 pm #72491Charlie BursellParticipant
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
-
August 30, 2010 at 7:58 pm #72492David BarrParticipant
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.
-
-
AuthorReplies
- The forum ‘Tcl Library’ is closed to new topics and replies.