473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XP exec background process

I was trying to exec a background process on XP using PHP CLI, but could
not get it to work. Suppose the command I want to spawn off is "cmd".
On *nix, it is as easy as putting ampersand "&" at the end of the command.

I tried the following on XP without working.

exec("cmd");
exec("cmd >NUL");
exec("cmd /c cmd");
exec("start /b cmd");

I tried many combination, but on each one, PHP waits for cmd to exit
before continuing.

Doing this in Windows script host (cscript) is simple:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd", 0, False

The "False" parameter causes the Run method to continue immediately
without waiting for the command to finish. So I could make my PHP file
exec a VBS file that does the actual background execution of my command.

PHP exec documentation says it will not wait if output of the command is
redirected somewhere, but this didn't seem to work for me. If anyone
has experience in doing something like this on Windows XP SP2, your
thoughts would be appreciated.

Thanks,
Shailesh

Mar 2 '06 #1
4 8639
http://de2.php.net/manual/en/function.exec.php#56599

I think what you've done was to use /b instead of /B , not sure, i am
Linux user. Also this is a real solution, however needs something for
download but not a problem i think:
http://de2.php.net/manual/en/function.exec.php#51599

http://de2.php.net/manual/en/function.exec.php#43917

http://de2.php.net/manual/en/function.exec.php#35731

Enjoy!

Mar 2 '06 #2
Drakazz wrote:
http://de2.php.net/manual/en/function.exec.php#56599

I think what you've done was to use /b instead of /B , not sure, i am
Linux user. Also this is a real solution, however needs something for
download but not a problem i think:
http://de2.php.net/manual/en/function.exec.php#51599

http://de2.php.net/manual/en/function.exec.php#43917

http://de2.php.net/manual/en/function.exec.php#35731

Enjoy!


Thanks! I used the COM method from--

http://de2.php.net/manual/en/function.exec.php#43917

--because I only need this script to run on Windows. BTW, Windows does
not care about capitalization on the command line.

Mar 3 '06 #3
"Shailesh Humbad" <hu*****@nowhere.invalid> posted:
BTW, Windows does not care about capitalization on the command line.


On DOS and Windows systems...

When working with paths and filenames, such items are case-insensitive.
DOS used to save all paths and filenames as 100% uppercase. However,
Windows will save the files in mixed case, even though the "file system"
treats it as case insensitive (providing only the visual benefits of upper
and lower case).

Passing switches/parameters on the command-line for different commands
may or may not be case-sensitive.

Some compilers are case-sensitive. Some tools are case-sensitive.

ntsd.exe command line parameters...
-g ignores initial breakpoint in debuggee
-G ignores final breakpoint at process termination

ml.exe assembler...
/Fr[file] Generate limited browser info
/FR[file] Generate full browser info

As far as the file system goes, you can type ml.exe any way you like.

As far as the switches go, the application processes the switches, and
you just don't know unless you know.

Hope this helps.

Jim Carlock
+"North Carolina Swimming Pools"+http://aquaticcreationcnc.com
Post replies to the group.
Mar 3 '06 #4
Jim Carlock wrote:
"Shailesh Humbad" <hu*****@nowhere.invalid> posted:
BTW, Windows does not care about capitalization on the command line.


On DOS and Windows systems...

When working with paths and filenames, such items are case-insensitive.
DOS used to save all paths and filenames as 100% uppercase. However,
Windows will save the files in mixed case, even though the "file system"
treats it as case insensitive (providing only the visual benefits of upper
and lower case).

Passing switches/parameters on the command-line for different commands
may or may not be case-sensitive.

Some compilers are case-sensitive. Some tools are case-sensitive.

ntsd.exe command line parameters...
-g ignores initial breakpoint in debuggee
-G ignores final breakpoint at process termination

ml.exe assembler...
/Fr[file] Generate limited browser info
/FR[file] Generate full browser info

As far as the file system goes, you can type ml.exe any way you like.

As far as the switches go, the application processes the switches, and
you just don't know unless you know.

Hope this helps.

Jim Carlock
+"North Carolina Swimming Pools"+http://aquaticcreationcnc.com
Post replies to the group.


I meant references to Windows file names and options for Windows
built-in commands (unless you can point out a counter-example).

I summarized the methods here:
http://www.somacon.com/p395.php
Mar 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: Matt | last post by:
I want have PHP call another process (another PHP script at the moment but it may end up being a binary) in the background and not wait for process to complete, but rather instantly jump the the...
3
by: Jerry | last post by:
I've found a problem with exec, passthru, shell_exec & system. I'm trying to run the following exec("sort -r -n -k2,2 r1.txt > r2.txt") with r1.txt being a numeric file. The file looks like...
1
by: Hal Vaughan | last post by:
I've been using Runtime.exec() like this: Runtime rt = Runtime.getRuntime(); try {Process p = rt.exec("MyCommand.bat");} catch (Exception e) {do stuff} When I start my Java classes, I start...
2
by: uwnewsgroup | last post by:
When I was using Runtime.exec(String cmd) to run a unix utility (join), and try to get its standard output by using Process.getOutputStream(), it blocks forever. I tried it using Java 1.4 and...
13
by: giloosh99 | last post by:
Exec, shell_exec, system, popen functions all run the process in the background. how can i get it to run the process normally. my code looks like this: <? exec("batch_file.bat"); ?> am i...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
11
by: news | last post by:
I've a PHP script that does some stuff, zips up some files, and starts an FTP process. I need it to do the Zip and FTP in the background and let the page finish, otherwise the user could have...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.