@EXEC command not work :(

@EXEC command not work :(

am 24.05.2010 20:35:02 von Loki

Hello,

PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a
executable located in c:\program files\ourexecutable\

it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...

Safe mode in PHP is OFF ...

Thanks by advance for you help
stephane

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: @EXEC command not work :(

am 25.05.2010 00:46:26 von Niel Archer

> Hello,
>
> PHP is installed in c:\program files\php
> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
> in the PHP script, we try to launch the command @exec(...) with a
> executable located in c:\program files\ourexecutable\
>
> it's not work :(
>
> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> to c:\scriptdir\ then it's work !!
>
> everything work good EXCEPT the @EXEC command ...
>
> Safe mode in PHP is OFF ...
>
> Thanks by advance for you help
> stephane

Is this operating in a CLI or web-server environment? If it is
web-server then it is probably a permissions issue. By default
Apache/PHP do NOT have permissions to access network resources. You must
create a user to run Apache and give that user the permissions needed.
This of course assumes you're using Apache, but I would guess similar
problem would happen with IIS.

> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: @EXEC command not work :(

am 25.05.2010 09:39:56 von Loki

I have a begin of explanation

When PHP is run as CGI it's work but with this header message :

'\\xxx.xxx.xxx.xxx\scriptdir'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Status: 200 OK
X-Powered-By: PHP/5.2.8
Content-type: text/html

@exec function work well


Now when PHP is run as a FAST-CGI then it's not work at
ALL (ie: just the @exec function not work, the other work ok!)


is it a normal behavior ?

thanks you by advance
stephane



On 5/25/2010 2:46 AM, Niel Archer wrote:
>> Hello,
>>
>> PHP is installed in c:\program files\php
>> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
>> in the PHP script, we try to launch the command @exec(...) with a
>> executable located in c:\program files\ourexecutable\
>>
>> it's not work :(
>>
>> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
>> to c:\scriptdir\ then it's work !!
>>
>> everything work good EXCEPT the @EXEC command ...
>>
>> Safe mode in PHP is OFF ...
>>
>> Thanks by advance for you help
>> stephane
>
> Is this operating in a CLI or web-server environment? If it is
> web-server then it is probably a permissions issue. By default
> Apache/PHP do NOT have permissions to access network resources. You must
> create a user to run Apache and give that user the permissions needed.
> This of course assumes you're using Apache, but I would guess similar
> problem would happen with IIS.
>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> Niel Archer
>
>


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: @EXEC command not work :(

am 25.05.2010 13:24:43 von Richard Quadling

On 24 May 2010 19:35, loki wrote:
> Hello,
>
> PHP is installed in c:\program files\php
> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
> in the PHP script, we try to launch the command @exec(...) with a executable
> located in c:\program files\ourexecutable\
>
> it's not work :(
>
> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> to c:\scriptdir\ then it's work !!
>
> everything work good EXCEPT the @EXEC command ...
>
> Safe mode in PHP is OFF ...
>
> Thanks by advance for you help
> stephane
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Can you show the exact exec() call please?

Most likely you are falling foul of the spaces in "Program Files".

Windows needs you to put spaces around any path that has spaces in it.

e.g.

"C:\Program Files\PHP\php.exe"

You can try this at the command prompt!

If you type ...

C:\Program Files\PHP\php.exe -v

you get ...

'C:\program' is not recognized as an internal or external command,
operable program or batch file.

Wrapping it in quotes will show you the PHP version.

There is a gotcha.

In the event that the program name (C:\Program Files\PHP\php.exe)
_AND_ a parameter to the program have spaces in, then you would
normally expect something like this ...

"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"

to work.

And it does from the command line.

But not when passed to the shell via the exec() method.

This was fixed in PHP about 2 years ago
(http://svn.php.net/viewvc?view=revision&revision=260429), so if you
are using a newer release of PHP, you can safely ...

exec('"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"');

If not, then use ...

exec('""C:\Program Files\PHP\php.exe" -f "C:\Program
Files\Scripts\script.php""');

That is

exec('
"
"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"
"
'
);


Richard.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: @EXEC command not work :(

am 25.05.2010 13:59:30 von harlequin2

Hello Stephane,
Hi Niel,

> > ...
> > but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> > to c:\scriptdir\ then it's work !!
> ...
> Is this operating in a CLI or web-server environment? If it is
> web-server then it is probably a permissions issue. By default
> Apache/PHP do NOT have permissions to access network resources. You must
> create a user to run Apache and give that user the permissions needed.
> This of course assumes you're using Apache, but I would guess similar
> problem would happen with IIS.

I ran into similar problems some years ago and I assume you run into comparable problems as I did:

---------------
Problem source:
---------------

* if you access a remote share interactively (i.e. through Windows Explorer), your stored user account information is validated on the remote computer and if the logged in user is allowed to access the share, you won't even know that an authentication happened.
* if the webserver (running under the localsystem account) tries to load or execute a remote script, the same authentication method happens but the localsystem accounts on the two computers (local web server and remote file server) are not the same, authentication fails causing exec() to fail too.

-----------------
Access debugging:
-----------------

* if the remote file server is a Windows 2000 and newer system, activate object access logging (through MMC, snap-in "Local Computer Policy" -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Audit Policy, option "Audit object access"
> after activating object access, rightclick one of the scripts that will be executed by the web server and set the object access options under "properties" -> "Advanced" -> "Auditing", add everyone and both successes and failures

Now execute the script on the web server and then check your file server's event log, security node if there are any failures logged.

-----------------------
How to solve the issue:
-----------------------

* add a user account with the same passwords on both the local web server and remote file server, change the service owner for Apache2/IIS to use the new account. If you are on a domain, it's even better to add a domain user with the same SID and use this one. Restart the service and check if the web server behaves normally, then retry the test.

* use the PSTools from Sysinternal to execute remote scripts. The tool PSExec takes a user name and password when calling remote script and first authenticates on the remote system before executing scripts (see http://technet.microsoft.com/de-de/sysinternals/bb897553.asp x)

Hope this helps!

Regards, Sascha
--
Freundliche Grüße / Kind regards,

Sascha Meyer
--------------------------------------------------
EE: http://www.experts-exchange.com/M_761556.html
ZCE: http://www.zend.com/en/yellow-pages#show-ClientCandidateID=Z END011290

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php