php-windows Digest 23 Dec 2005 01:39:57 -0000 Issue 2854
Topics (messages 26586 through 26589):
Re: exec() problem
26586 by: trystano.aol.com
26587 by: El Bekko
26588 by: Jay Blanchard
26589 by: Fábio Ottolini
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Maybe its something to do with who the system is trying to run the
command under?
I remember someone having problems try run WinZip through the exec()
command and it was down to what the service was being run under.
Tryst
-----Original Message-----
From: El Bekko <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wed, 21 Dec 2005 13:03:58 +0100
Subject: Re: [PHP-WIN] exec() problem
Fábio Ottolini wrote:
> To clarify it a little bit more, I have changed the code a bit:
> > $command = "nslookup -type=mx $domain 2>&1";
> > exec ( $command, $result );
> > print_r($result);
> > And the result on the browser is:
> > Array ( [0] => Access is denied. ) > > Any clues?
> > '>'-- Mensagem Original --
> '>'Date: Tue, 20 Dec 2005 10:43:48 -0200
> '>'From: Fábio Ottolini <[EMAIL PROTECTED]>
> '>'Reply-To: [EMAIL PROTECTED]
> '>'To: [email protected]
> '>'Subject: [PHP-WIN] exec() problem
> '>'
> '>'
> '>'Dear Comrades,
> '>'
> '>'Can someone please explain why this script is not working on my
win2k
> '>'box with PHP 4.3.4?
> '>'
> '>'<?php
> '>'
> '>'$email="[EMAIL PROTECTED]";
> '>'
> '>'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 Ottolini
> '>'
> '>'--
> '>'PHP Windows Mailing List (http://www.php.net/)
> '>'To unsubscribe, visit: http://www.php.net/unsub.php
> '>'
Try using system()
-- PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin 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="[EMAIL PROTECTED]";
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 Ottolini
I 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";
--- End Message ---
--- Begin Message ---
[snip]
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.
[/snip]
Make sure that PHP is running with safe_mode 'off' in the ini
--- End Message ---
--- Begin Message ---
Thank you all for your answers! What was causing my problem? IIS Lockdown
Tool. Locks things so much that executing system functions even with
administrator rights is impossible. Solution? Remove the tool and make the
suggested changes manually, leaving some changes behind.
Kind Regards,
Fábio Ottolini
----- Original Message -----
From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[email protected]>
Sent: Wednesday, December 21, 2005 1:30 PM
Subject: RE: [PHP-WIN] exec() problem
[snip]
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.
[/snip]
Make sure that PHP is running with safe_mode 'off' in the ini
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---