holandes777 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use Time::HiRes qw( usleep time gettimeofday tv_interval ); use LWP; use HTTP::Request::Common; use URI::Escape; use CGI qw/:standard *table start_ul use_named_parameters/; # load + standard CGI routines use CGI::Carp qw /fatalsToBrowser/; use CGI::Pretty ":standard"; print "Content-Type: text/html\r\n\r\n"; print "<HTML>\n"; print "<HEAD>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "<CENTER>\n"; my @SNSresponse; sSendToSNS('192.168.0.8','80','SNSphone2e.pl','EX=RUT&LOGIN=test&PASSW +ORD=test&FLOORID=TEST&HPNUM=1234','me',\@SNSresponse); print "</CENTER>\n"; print "</BODY></HTML>\n"; exit; sub sSendToSNS { my $ip = $_[0]; my $port = $_[1]; my $script = $_[2]; my $msg = $_[3]; my $caller = $_[4]; my $retarray = $_[5]; my $retval = 0; my $response; if ( my $ua = LWP::UserAgent->new ) { $ua->timeout(30); my $request = POST( "http://$ip/scripts/$script", Content_Type => 'form_data', Content => [ message => [$msg] ]); # 20030317 gk - this methodology sends a properly formatted POST + with key/value pairs. # it does not work because it does not ADD to the POST but repla +ces it # need to fix this $response = $ua->request($request); print "\$ip=|$ip|, \$script=|$script|, \$msg=|$msg|<BR>\n"; if ( $response->is_success ) { my $returnmsg = $response->content; if ( grep(/\%\%DATA RECEIVED/,$returnmsg) ) { my @returnline = split(/\n/,$returnmsg); foreach my $line ( @returnline ) { print "\$line=|$line|<BR>\n"; if ( substr($line,0,4) eq 'SNS:' ) { push(@$retarray,$line); } # end if ( substr($line,0,4) eq 'SNS:' ) } # end foreach my $line ( @returnline ) } # end if ( grep(/\%\%DATA RECEIVED/,$returnmsg) ) } else { print "failed response $!<BR>\n"; } # end if ( $response->is_success ) } else { print "failed ua $!<BR>\n"; } # end if ( my $ua = LWP::UserAgent->new ) return; }
[root@localhost cgi-bin]# perl kk.pl Content-Type: text/html <HTML> <HEAD> </HEAD> <BODY> <CENTER> $ip=|192.168.0.8|, $script=|SNSphone2e.pl|, $msg=|EX=RUT&LOGIN=test&PA +SSWORD=test&FLOORID=TEST&HPNUM=1234|<BR> $line=|<HTML>|<BR> $line=|<HEAD></HEAD>|<BR> $line=|<BODY>|<BR> $line=|SNS:%%DATA RECEIVED|<BR> $line=|SNS:ACK=|<BR> $line=|SNS:HPNUM=1234&USERTYPES=As,Bs|<BR> $line=||<BR> $line=||<BR> $line=|TIME=2007-05-02 17:50:05.114979&ETIME=1178149805.114979</BODY>< +/HTML>|<BR> </CENTER> </BODY></HTML> [root@localhost cgi-bin]#
$ip=|192.168.0.8|, $script=|SNSphone2e.pl|, $msg=|EX=RUT&LOGIN=testcas +hier&PASSWORD=testcashier&FLOORID=TEST&HPNUM=1234| failed response Permission denied
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mod_perl, apache and permissions
by TOD (Friar) on May 03, 2007 at 02:15 UTC | |
by holandes777 (Scribe) on May 03, 2007 at 18:14 UTC | |
by Anonymous Monk on May 04, 2007 at 08:34 UTC | |
by holandes777 (Scribe) on May 11, 2007 at 00:40 UTC | |
|
Re: mod_perl, apache and permissions
by almut (Canon) on May 03, 2007 at 23:06 UTC |