ID:               25361
 Comment by:       t03 at springtimesoftware dot com
 Reported By:      sam at freepeers dot com
 Status:           No Feedback
 Bug Type:         Program Execution
 Operating System: Windows 2000
 PHP Version:      4.3.2
 New Comment:

Under Windows, here is a workaround to the bugs in PHP and Windows:

1. Copy cmd.exe into the main PHP folder (usually C:\php or C:\Program
Files\php). This gives PHP authorization to run it.

2. In your PHP code, execute the command "Exec.cmd <command> <args>".
Each arg can be quoted. Consider calling escapeshellcmd or
escapeshellarg.

3. Create a file Exec.cmd where your PHP code can find it. It should
contain the following:

rem @echo off
rem echo Args: %1 %2 %3 %4 %5 %6 %7 %8 %9
start "Exec.cmd Is Running" /b %1 %2 %3 %4 %5 %6 %7 %8 %9
exit

4. Change the /b to /w for synchronous execution.

5. This is rough. It should be changed to return the command's error
code (errorlevel), etc.

David Spector


Previous Comments:
------------------------------------------------------------------------

[2007-08-11 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2007-08-03 09:26:56] [EMAIL PROTECTED]

>From the cmd.exe /? help

If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic
is
used to process quote (") characters:

1. If all of the following conditions are met, then quote characters
on the command line are preserved:

- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.

2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.

My intent is to force the command line supplied by exec() et. al. to be
wrapped in a pair of quotes, thus forcing option 2 to be used.

For older windows (9x), using command.com, the help is ...

/C string       Carries out the command specified by string, and then
stops.

If 9x is not a concern (I'm getting it tested next week as I don't have
a 9x machine at hand), then the first patch could be used which only
wraps "" around NT+.



------------------------------------------------------------------------

[2007-08-03 09:10:28] [EMAIL PROTECTED]

Non volatile link (Sorry Pierre) :
http://rquadling.php1h.com/proc_open.c.diff2

------------------------------------------------------------------------

[2007-08-03 09:04:55] [EMAIL PROTECTED]

Index: proc_open.c
===================================================================
RCS file: /repository/php-src/ext/standard/proc_open.c,v
retrieving revision 1.57
diff -u -r1.57 proc_open.c
--- proc_open.c 28 May 2007 23:00:25 -0000      1.57
+++ proc_open.c 2 Aug 2007 09:30:57 -0000
@@ -740,7 +740,7 @@
        if (bypass_shell) {
                newprocok = CreateProcess(NULL, command, &security, &security, 
TRUE,
NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, &si, &pi);
        } else {
-               spprintf(&command_with_cmd, 0, "%s /c %s", GetVersion() < 
0x80000000
? COMSPEC_NT : COMSPEC_9X, command);
+               spprintf(&command_with_cmd, 0, "%s /c \"%s\"", GetVersion() <
0x80000000 ? COMSPEC_NT : COMSPEC_9X, command);
 
                newprocok = CreateProcess(NULL, command_with_cmd, &security,
&security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd,
&si, &pi);
 


------------------------------------------------------------------------

[2007-08-02 09:33:59] [EMAIL PROTECTED]

It may be that the /S is not required.

http://pastie.caboo.se/84306

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/25361

-- 
Edit this bug report at http://bugs.php.net/?id=25361&edit=1

Reply via email to