Re: exec() problem
| From: | El Bekko | Date: | Wed, 21 Dec 2005 15:27:52 +0000 |
| Subject: | Re: exec() problem | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-26587@lists.php.net to get a copy of this message | ||
Fábio Ottolini wrote:
Dear Comrades, Can someone please explain why this is script is not working on my win2k box with PHP 4.3.4? <?php $email="fabio.ottolini@globo.com"; list($alias, $domain) = split("@", $email); $command = "nslookup -type=mx $domain"; exec ( $command, $result ); $i = 0; while ( list ( $key, $value ) = each ( $result ) ) { if ( strstr ( $value, "mail exchanger" ) ) { $nslookup[$i] = $value; $i++; } } while ( list ( $key, $value ) = each ( $nslookup ) ) { $temp = explode ( " ", $value ); $mx[$key][0] = $temp[3]; $mx[$key][1] = $temp[7]; $mx[$key][2] = gethostbyname ( $temp[7] ); } array_multisort ( $mx ); print_r($mx); print "<br><br>"; print $mx[0][1]; ?> The same script works fine in another win2k box running PHP version 5. Strange is that if I add print $result; right after exec ( $command, $result ); nothing is printed. When the script runs on the machine that works it prints Array obviously. So, my guess is that $command is never being executed. BTW, PHP is not running on safe_mode and the nslookup command works fine on both machines. Any help would be very much appreciated. Kind Regards, Fabio OttoliniI tested your script on my Apache server running PHP 5.0 on WinXPPro... it gives these errors: ---- Warning: Variable passed to each() is not an array or object in D:\webserver\www\ICStrategy_MySQL\tests\exec.php on line 17 Notice: Undefined variable: mx in D:\webserver\www\ICStrategy_MySQL\tests\exec.php on line 24 Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in D:\webserver\www\ICStrategy_MySQL\tests\exec.php on line 24 Notice: Undefined variable: mx in D:\webserver\www\ICStrategy_MySQL\tests\exec.php on line 26 Notice: Undefined variable: mx in D:\webserver\www\ICStrategy_MySQL\tests\exec.php on line 28 ---- Ok, after some messing around I fixed it: Replace $command = "nslookup -type=mx $domain"; with $command = "nslookup $domain";