Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Executing two scripts concurrently on your home machine (http://www.programmingforums.org/showthread.php?t=13295)

grimpirate Jun 6th, 2007 11:25 PM

Executing two scripts concurrently on your home machine
 
I'd like to know how I can run the same script twice (on the command line or even in my browser) so that I can get overlapping outputs on my windows machine. So, for instance if the script were something simplistic like the following:[PHP]<?php
while(true){
fwrite(STDOUT, "Process ID: " . getmypid() . "\n");
sleep(1);
}
?>[/PHP]The output in the command line would be something along the lines of:
:

Process ID: 3894
Process ID: 3894
Process ID: 3894
Process ID: 2295
Process ID: 3894
Process ID: 2295
...


dr.p Jun 7th, 2007 9:07 AM

I would probably write a Perl script (on windows) that creates one or more child processes that each connect to the given URL and download the results to a local, temporary, HTML file. Then, if possible, the script would display the local pages in my default browser for me.

But, why do you want to do this?

grimpirate Jun 7th, 2007 10:47 AM

I wanted to do this to test a file locking mechanism. I was actually just sort of hoping it would be some sort of command line input I had to enter. I just opened up to command prompts and typed in the same command, ALT+TAB really quick and got some overlapping instructions. Not the most efficient way to look at the output lol but it JUST met the requirements. Needless to say the file-locking mechanism I was trying to implement didn't work.

mackenga Jun 10th, 2007 5:49 AM

Sadly the Windows command-line shell is a bit restrictive. Hailing from the days of non-multitasking OSes it doesn't spawn background processes conveniently like Unix shells do. Even its I/O redirection is still pretty poor. I pity people stuck developing and testing on Win32 - it's such a weird, archaic system.


All times are GMT -5. The time now is 3:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC