MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Globalsub error



******    message to minivend-users from Mike Lerley <mike@bfent.com>     ******

I am trying to run the following GlobalSub (as defined in minivend.cfg):

GlobalSub <<EOF

sub SendOrder {
use CGI;
my $x=0;
my ($code, $qty,
%Stuff,$custnum,$remote,$port,$AF_INET,$SOCK_STREAM,$sockaddr);
my
($name,$aliases,$proto,$type,$len,$thataddr,%Pairs,$output,$key,$len,@resp);
my ($rlen,$lbl,$val,$that,%Rsp);

while (@_) {
        $code=shift;
        $qty=shift;
        $Stuff{"DTL_LCC".$x}=$code;
        $Stuff{"DTL_QTY".$x}=$qty;
        $x++;
}

$custnum="003141";

$remote='allflus2.aent.com';
$port=80;
$AF_INET=2;
$SOCK_STREAM=1;
$sockaddr='S n a4 x8';
($name,$aliases,$proto)=getprotobyname('tcp');
($name,$aliases,$port,$proto)=getservbyname($port,'tcp') unless $port =~
/^\d+$/;
($name,$aliases,$type,$len,$thataddr)=gethostbyname($remote);
$that=pack($sockaddr,$AF_INET,$port,$thataddr);

if(!socket(SOCK,$AF_INET,$SOCK_STREAM,$proto)) { die $!; }

if(!connect(SOCK,$that)) { die $!; }

%Pairs=("query","0","Format","response","Conf","videohuttest.conf","HDR_AECCUSTNUM","$custnum");
$output="";

foreach $key (keys(%Pairs)) {
        $output.=CGI::escape($key)."=".CGI::escape($Pairs{$key})."&";
}
foreach $key (keys(%Stuff)) {
        $output.=CGI::escape($key)."=".CGI::escape($Stuff{$key})."&";
}
chop($output);
$len=length($output);

select(SOCK);
$|=1;
print SOCK "POST /cgi-bin/WebAEC HTTP/1.0\n";
print SOCK "User-Agent: Lerlzilla-0.1\n";
print SOCK "Content-type: application/x-www-form-urlencoded\n";
print SOCK "Content-length: $len\n\n";
print SOCK "$output\n";
select(STDOUT);
@resp=<SOCK>;
close(SOCK);

$rlen=@resp;

for($x=5;$x<$rlen;$x++) {
        ($lbl,$val)=split(/=/,$resp[$x]);
        chomp($val);
        $Rsp{$lbl}=$val;
}

return
"BO=$Rsp{'HDR_TOTALQTYBO'}&TID=$Rsp{'TRN_ID'}&ON=$Rsp{'HDR_AECORDERNUM'}&TN=$Rsp{'BT_TOTALNUM'}";
}
EOF


But when I call it with 
[perl sub]SendOrder [item-list][item-code]
[item-quantity][/item-list][/perl]

The browser gives me "FATAL ERROR   Search pattern not terminated at
(eval 51) line 1"

When running minivend in debug mode (-D0), the console tells me
Bareword "item" not allowed while "strict subs" in use at (eval 51) line
1
three times.

Note, however, that the following very similar GlobalSub works just
fine:

GlobalSub <<EOF

sub check_inv {
use CGI;

my $code;
($code)=$_[0];
my ($name,$aliases,$proto,$type,$thataddr,$len,$x,$key,$lbl,$val,%Rsp);
my $remote='allflus2.aent.com';
my $port=80;
my $AF_INET=2;
my $SOCK_STREAM=1;
my $sockaddr='S n a4 x8';
($name,$aliases,$proto)=getprotobyname('tcp');
($name,$aliases,$port,$proto)=getservbyname($port,'tcp') unless $port =~
/^\d+$/;
($name,$aliases,$type,$len,$thataddr)=gethostbyname($remote);
my $that=pack($sockaddr,$AF_INET,$port,$thataddr);

if(!socket(SOCK,$AF_INET,$SOCK_STREAM,$proto)) { die $!; }

if(!connect(SOCK,$that)) { die $!; }

my
%Pairs=("query","1","Format","response","Conf","videohuttest.conf","HDR_AECCUSTNUM","003141","DTL_LCC0","$code","TRN_INV","on","DTL_QTY0","1000");
my $output="";

foreach $key (keys(%Pairs)) {
        $output.=CGI::escape($key)."=".CGI::escape($Pairs{$key})."&";
}
chop($output);
$len=length($output);

select(SOCK);
$|=1;
print SOCK "POST /cgi-bin/WebAEC HTTP/1.0\n";
print SOCK "User-Agent: Lerlzilla-0.1\n";
print SOCK "Content-type: application/x-www-form-urlencoded\n";
print SOCK "Content-length: $len\n\n";
print SOCK "$output\n";
select(STDOUT);
my @resp=<SOCK>;
close(SOCK);

my $rlen=@resp;

for($x=5;$x<$rlen;$x++) {
        ($lbl,$val)=split(/=/,$resp[$x]);
        chomp($val);
        $Rsp{$lbl}=$val;
}

if($Rsp{'DTL_QTY0'}>0) { return 'In Stock!'; }
else { 
        if($Rsp{'DTL_ERR0'} == 3) {
                return 'Sorry, item not found.';
        }
        else {
                return 'Sorry, currently out of stock.';
        }
}

}
EOF


Please note also that the first sub, when run as a standalone perl
script, works very nicely.  Anybody have any ideas?  I don't understand
either error message because they don't seem to apply, which probably
means there is something greater at work here.  Please help me!
-mike


-- 
Mike Lerley, Technical Systems Administrator
Goold Health Systems
24 Stone Street
Augusta, ME 04330
Email mike@bfent.com
Phone (207) 622-3298
Fax   (207) 623-5125

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS$/CM d- s:+ a-- C++++ UL++++U+CA+ P++++$ L++++
E--- W+++ N !o K- w--- !O M-- V PS PE++ Y PGP- t+ 5+
X+++ R- tv+ b+ DI++ D++ G e++ h--- r+++ y+++
------END GEEK CODE BLOCK------
http://www.ebb.org/ungeek/
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: