Asheeown Posted September 10, 2008 Share Posted September 10, 2008 I need to get the process ID of a background process I'm executing and I can't seem to get it. OS: Windows $dir = "C:/xampp/php"; $php_path = "C:/xampp/php/php.exe"; $file = "myscript.php"; $cmd_options = "-t " . time(); $wscript = new COM('WScript.Shell'); $Command = $wscript->Run("$php_path $dir/$file", 0, false); Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/ Share on other sites More sharing options...
DarkWater Posted September 10, 2008 Share Posted September 10, 2008 ps aux | grep 'php' | awk '{print $2}' EDIT: Nvm, you're on Windows. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-638728 Share on other sites More sharing options...
Asheeown Posted September 10, 2008 Author Share Posted September 10, 2008 Wouldn't work anyway, I need the specific PID that was started on that page. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-638731 Share on other sites More sharing options...
Asheeown Posted September 10, 2008 Author Share Posted September 10, 2008 Basically, I want to access one of the properties of the COM Object. Now, com_get would work fantastic, however it has been discontinued ever since php5, this is the note that comes along with the manual for COM_GET Note: This function does not exist in PHP 5; instead, you should use the regular and more natural OO syntax to access properties or call methods. If anyone could point me in the direction of how to write an OO syntax for this situation it would be the most amazing thing ever. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-638737 Share on other sites More sharing options...
Asheeown Posted September 11, 2008 Author Share Posted September 11, 2008 Okay, guess I'll bump it again even though it seems worthless Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-639430 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 In order to get properties that you'd otherwise get with com_get(), you do this: $wscript = new COM('WScript.Shell'); echo $wscript->property; As opposed to: com_get($com, 'property'); Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-639440 Share on other sites More sharing options...
Asheeown Posted September 13, 2008 Author Share Posted September 13, 2008 Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `ProcessId': Unknown name. ' in C:\xampp\htdocs\EGM\test.php:12 Stack trace: #0 C:\xampp\htdocs\EGM\test.php(12): unknown() #1 {main} thrown in C:\xampp\htdocs\EGM\test.php on line 12 $dir = "C:/xampp/php"; $php_path = "C:/xampp/php/php.exe"; $file = "myscript.php"; $cmd_options = "-t " . time(); $wscript = new COM('WScript.Shell'); $Command = $wscript->Run("$php_path $dir/$file", 0, false); $PID = $wscript->ProcessId; echo $PID; Everything works fine until I add the $PID = $wscript->ProcessId; in. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-640622 Share on other sites More sharing options...
Asheeown Posted September 15, 2008 Author Share Posted September 15, 2008 Bump for 2 days gone by Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-642407 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 Do print_r($wscript) and tell me what it shows (just curious. It may also help. =P) Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-642418 Share on other sites More sharing options...
Asheeown Posted September 19, 2008 Author Share Posted September 19, 2008 Sorry it took so long but no it didn't work, it printed com Object on the screen and the process still runs in the background. If I print the command it returns a 0, probably 0 or 1 for telling php if it's waiting for execution to finish. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-645256 Share on other sites More sharing options...
Asheeown Posted September 22, 2008 Author Share Posted September 22, 2008 4 days...bump Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-648180 Share on other sites More sharing options...
Guest Xanza Posted September 22, 2008 Share Posted September 22, 2008 Keep in mind, I believe with windows there is no process memory... Each new opened process is just given a consecutive process ID... Meaning if you're looking for a specific program, to grab output maybe via PID, then you might (in a second script run) be polling the wrong program for the right information. Just something to think about. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-648226 Share on other sites More sharing options...
Asheeown Posted September 22, 2008 Author Share Posted September 22, 2008 I'm looking to kill the process that's all. When the user hasn't updated his status, meaning refreshing the page, a cron job will run through for inactive users up to 10 minutes and kill inactive user processes. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-648236 Share on other sites More sharing options...
Asheeown Posted September 23, 2008 Author Share Posted September 23, 2008 Bump Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-648973 Share on other sites More sharing options...
Asheeown Posted September 24, 2008 Author Share Posted September 24, 2008 Bump, probably last time I'm going to because it just seems hopeless at this point Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-649804 Share on other sites More sharing options...
Asheeown Posted September 25, 2008 Author Share Posted September 25, 2008 Okay I'll leave it with another question. If in the same script as executing the background script did I run a tasklist command that pulled an entire list of processes could I pull the PID from there? Meaning that once the script has executed the list command will run and php will grab the absolute last process called "php.exe" and get it's PID since processes are listed in order of executed on tasklist. Would this work or if someone executed at the same time as someone else could the PIDs get mixed up? Please someone answer this question since it's based on pure logic and doesn't have anything to do with Windows or Linux OS. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-649973 Share on other sites More sharing options...
Asheeown Posted September 27, 2008 Author Share Posted September 27, 2008 NO ONE can answer that question? Really? I see people post the absolute dumbest questions on this forum and still get answers, I post a simple logic question and it just gets passed by? I leave posts for days but it doesn't matter, 10 minutes after I bump it 90% dumb topics cover it up and throw it off to the next page. I would love a simple yes or no answer to my question I posted above, I'll quote it every day until I get an answer. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-652044 Share on other sites More sharing options...
Guest Xanza Posted September 27, 2008 Share Posted September 27, 2008 The reason why no one has answered your question is that you basically demand it be answered. If you yell at someone: "Do this, do that!" reguardless of who you are and your reasons for being so pushy - no one is going to want to do or answer. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-652099 Share on other sites More sharing options...
Asheeown Posted September 28, 2008 Author Share Posted September 28, 2008 Did you happen to take a look at the 14 other posts before that one? Oh yeah they were bumps, DAYS apart from each other, it just gets a little annoying when you ask a logical question that someone could simply answer yet they just don't look or post something stupid like your post relating absolutely nothing towards the topic just here to be a dick. So please don't post if you don't have anything beneficial to contribute. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-652157 Share on other sites More sharing options...
corbin Posted September 28, 2008 Share Posted September 28, 2008 I hate when people get demanding. I must say I agree with Xanza. I don't mind bumps, in fact I encourage them because things need to get answered. A simple "bump" or "Please help" works fine. A "F------ HELP ME NOW" just pisses people off. I have no experience with COM objects, but try a var_dump on it and see if you can find the property you want in the list. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-652204 Share on other sites More sharing options...
Asheeown Posted October 2, 2008 Author Share Posted October 2, 2008 Var_dump just brings back com_object no information Bump. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-655245 Share on other sites More sharing options...
Asheeown Posted October 5, 2008 Author Share Posted October 5, 2008 Bump Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-657817 Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 I hate when people get demanding. I must say I agree with Xanza. I don't mind bumps, in fact I encourage them because things need to get answered. A simple "bump" or "Please help" works fine. A "F------ HELP ME NOW" just pisses people off. I have no experience with COM objects, but try a var_dump on it and see if you can find the property you want in the list. Exactly, I have no experience with COM either. Hopefully someone does, but I doubt it. Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-657819 Share on other sites More sharing options...
Asheeown Posted October 7, 2008 Author Share Posted October 7, 2008 Bump :-\ Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-659285 Share on other sites More sharing options...
Asheeown Posted October 10, 2008 Author Share Posted October 10, 2008 Bump Quote Link to comment https://forums.phpfreaks.com/topic/123695-solved-process-id/#findComment-661500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.