Page 1 of 1
using system from php
Posted: Fri Mar 23, 2007 11:16 am
by thundrax
Guys, I am having a strange problem with php calling external applications such as perl or even 'ls'.
such as system('ls');
I get not found error. But the real annoying thing is that it works most of the time, but then something happens and it breaks. Everything else works fine, except calling external (to php) applications. The only way to restore it is by restarting apache. Any advice you guys have would be greatly appreciated.
Posted: Fri Mar 23, 2007 11:30 am
by RobertGonzalez
Start with this... run the following in a new file and tell us the results please.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "
";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>
Posted: Fri Mar 23, 2007 11:54 am
by thundrax
Here:
PHP Version: 5.1.6
PHP OS: Linux
Error Reporting: 2039 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: On
Short Tags: On
Display Errors: On
Magic Quotes GPC: Off
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: /opt/apps/php5/lib/php.ini
Loaded Extensions:
xmlwriter libxml dom xmlreader
xml tokenizer standard SimpleXML
SPL session soap PDO
SQLite Reflection posix PDO_OCI
pdo_mysql oci8 mysqli mysql
ldap iconv hash gmp
gettext gd date curl
ctype calendar zlib pcre
apache2handler
Posted: Fri Mar 23, 2007 12:22 pm
by RobertGonzalez
That is odd. Can you tail your apache error log? Say, the last 100 lines or so.
Posted: Fri Mar 23, 2007 12:34 pm
by thundrax
The thing is it doesn't happen all the time. And now its working fine.
It seems that maybe apache deamon gets corrupted and doesn't know how to run stuff. Is that possible or what could be causing that.
Posted: Fri Mar 23, 2007 1:15 pm
by RobertGonzalez
It could be any number of things, though I tend to think it is not so much a PHP issue as it may be an apache issue or even a system issue. But to be honest, I am clueless. Let this thread sit a bit. There are a lot of really sharp *nix users here that could help you.