php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28101 CLI scripts specified with UNC paths using system() have Win. default work. dir
Submitted: 2004-04-22 03:23 UTC Modified: 2004-04-22 08:16 UTC
From: bksmith at windlogics dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.6 OS: Windows 2000
Private report: No CVE-ID: None
 [2004-04-22 03:23 UTC] bksmith at windlogics dot com
Description:
------------
When a CLI script passed to the php interpreter with a UNC path, the system(program, return value) function call does not function in the same way as it does when a CLI script is passed to the interpreter with a non-UNC path.  The problem seems to be that php bases its idea of the working directory on the path to the script it is running, rather than the directory in which php was run.  This makes sense in the context of a web server, but does not seem to make sense on the command line.
The example provided does not fail due to this problem because of the example's extreme simplicity, but illustrates the error message provided by CMD.exe when this issue arises.  One can easily imagine instances where a script makes assumptions about working directory that are invalid when the working directory becomes C:\WINNT\SYSTEM32 or the like.
For programmers attempting to migrate from other languages, it may be confusing that the working directory is not actually the directory they are working in.

Reproduce code:
---------------
<?php
$retString = system("echo what", $retVal);
?>


Expected result:
----------------
E:\WIND_PRODUCTION\bin>php test.php
Content-type: text/html
X-Powered-By: PHP/4.3.6

what


Actual result:
--------------
E:\WIND_PRODUCTION\bin>php \\37bananas\work\WIND_PRODUCTION\bin\test.php
CMD.EXE was started with '\\37bananas\work\WIND_PRODUCTION\bin' as the current d
irectory path.  UNC paths
are not supported.  Defaulting to Windows directory.
Content-type: text/html
X-Powered-By: PHP/4.3.6

what


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-22 08:16 UTC] edink@php.net
You are using CGI version (php -v). Use php.exe from cli directory.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 00:01:31 2024 UTC