[ic] Calling a PERL function using a custom defined Globalsub

Kevin Walsh interchange-users@interchange.redhat.com
Thu Jan 3 03:14:01 2002


> We are trying to do a custom subroutine that performs an HTTP post to
> another server.
> 
> In our Globalsub we created a new routine called posttoserver which is the
> starting point for our work, however, we cannot get this simple function to
> work within Interchange:
> 
> Here is an example:
> 
> ********
> LINE# ACTUAL TEXT
>
> 1     GlobalSub <<EOF
> 2     sub posttoserver {
> 3
> 4     use strict;
> 5     use sigtrap;
> 6     use IO::Socket::INET;
> 7
> 8     my $result =  IO::Socket::INET->new("www.fredpope.com:80");
> 9     print $result "GET \r\n";
> 10    my @out=<$result>;
> 11
> 12    close ($result);
> 13
> 14    print("Content-Type: text/html\n\n");
> 15    print ("@out");
> 16    }
> 17    EOF
>
> ********
> 
> If I remove a line at the top and at the bottom, this runs predictably, as
> filename.pl in the cgi-bin directory but when I call it from interchange,
> nothing happens. Here is how I am calling it:
> 
> [perl subs=yes]posttoserver[/perl]
> 
> It seems that we cannot make a call to the line 6 without it hanging up.
>
It looks to me as if you are expecting the output of your "print"
statements to somehow get routed onto the web page generated by
Interchange.

Try this:

    Delete line 14.
    Change line 15 to simply return "@out";

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.uk.com
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/