Hi All: Basically, a program that talks to a server and gets a response when run from the command line gets a "permission denied" when run through apache.
 
This may be the wrong place for this, but since you guys are great at this, one of you may have an idea. Otherwise, if you have a good forum to send me to I would appreciate it.
 
Here Goes:
 
apache runs as user snr and the files are 755, user and group snr. They are in /var/www/cgi-bin.  
#!/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; }
 
if the script is run from the command prompt the result is that it can receive data from the other server.
 
[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]#
 
The same script run though a browser: http://127.0.0.1/cgi-bin/kk.pl
 
$ip=|192.168.0.8|, $script=|SNSphone2e.pl|, $msg=|EX=RUT&LOGIN=testcas +hier&PASSWORD=testcashier&FLOORID=TEST&HPNUM=1234| failed response Permission denied

In reply to mod_perl, apache and permissions by holandes777

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.