|
|
 |
Talking about PHP/PERL...
date posted 10th January 2003 18:27
I'm executing some perl from php using system_exec (don't want to use
virtual as I want to post variables to the perl ... code at bottom) ... and
it works fine... apart from every so often (more often than I would like!)
the perl returns
Can't locate object method "request" via package "Apache" at
/usr/lib/perl5/5.00503/CGI.pm line 258, chunk 241.
Tried it on 2 servers (both raq4 tho) with the same result ... restarting
the httpd fixes it... for a while...
Anybody any clue as to why it's happening?... I have upgraded the CGI.pm and
it never fails from the command line even when run as httpd user.
TIA, Andy.
PHP Code:
// preparing the arguments passed to this PHP page
$QSTRING = $QUERY_STRING;
foreach ($HTTP_POST_VARS as $header=> $value ){
if(is_array($value)){
foreach ($value as $header1=> $value1){
if($QSTRING==""){
$QSTRING =
urlencode(escapeshellcmd($header)).'='.urlencode(escapeshellcmd($value1));
}else{
$QSTRING =
$QSTRING.'&'.urlencode(escapeshellcmd($header)).'='.urlencode(escapeshellcmd
($value1));
}
}
}else{
if($QSTRING==""){
$QSTRING =
urlencode(escapeshellcmd($header)).'='.urlencode(escapeshellcmd($value));
}else{
$QSTRING =
$QSTRING.'&'.urlencode(escapeshellcmd($header)).'='.urlencode(escapeshellcmd
($value));
}
}
}
//Check for naughty values
$QSTRING=str_replace('', urlencode('>?'), $QSTRING);
$QSTRING=str_replace(urlencode('?>'), urlencode('>?'), $QSTRING);
$QSTRING=str_replace(urlencode('?').'>', urlencode('>?'), $QSTRING);
$QSTRING=str_replace('?%3E', urlencode('>?'), $QSTRING);
putenv('REQUEST_METHOD=POST');
putenv('CONTENT_TYPE=application/x-www-form-urlencoded');
putenv('CONTENT_LENGTH='.strlen($QSTRING));
unset($return_array);
$tmpfname = tempnam ("/tmp", "Regsys");
$fp = fopen($tmpfname, "w");
fwrite($fp, $QSTRING);
fclose($fp);
$return=shell_exec($CGISCRIPT.''.implode($return_array,"
"));
|
 |
|