开发者

Problem with passthru on server

I have a problem trying to run passthru function in my php code (Joomla module). the code is following (this is only a snippet)

开发者_如何转开发ob_start();
passthru("/usr/bin/whois 85.70.231.130 | /usr/bin/grep 'address:'",$code);
$whoisData = ob_get_contents();
ob_end_clean();
$whoisData = str_replace("address:", "", $whoisData);
$whoisArray = split("\n",$whoisData);
echo trim($whoisArray[1]);    

when I run this on my localhost, it echoes what it should, but when I run this code on the production server, it echoes nothing and the $code variable contains 127 (command not found). I tryied add absolute paths to these commands into the passthru function, but it didn't helped. Interesting is, that when I run the code right from terminal via ssh and php command, it runs well, but when it's called from application context it doesn't. Does anybody know what I should to do?thanks

SOME EDITS.. safe_mode is on webserver does not see into /usr/bin and /bin/ folders so what is the best way how to run these commands from php?


usr/bin/grep doesn't look like a valid path to a command.

The missing / at the beginning of the path to the second command might explain the command not found error... even if the first whois command is found.


Have you looked to see if your webserver / php is running chrooted?

print_r(glob('/*'));
if (file_exists('/usr/bin/grep') && file_exists('/usr/bin/whois')) {
   print "maybe its a permissions thing?\n";
} else {
   print "can't see executables required\n";
}

should give you a clue.


So I have already solved my problem with phpwhois library. I seems like with my server configuration is it unlikely that these functions will be working well. So thanks for your help:)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜