473,405 Members | 2,154 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,405 software developers and data experts.

getting process id in php

shoonya
161 100+
i am using windows XP

and using
popen("start notepad","r");

to start a note pad
now how can i get the process id of this notepad

shoonya
Jun 18 '07 #1
4 9399
Atli
5,058 Expert 4TB
Check out the proc_get_status() function.
It should get you what you need.
Jun 18 '07 #2
shoonya
161 100+
thanks a lot atil

but when I am using popen to open the note pad it's giving error
[PHP]
PHP Warning: proc_get_status(): supplied resource is not a valid process resource in C:\Program Files\Apache Group\Apache2\htdocs\quedge3\index\test.php on line 46[/PHP]

i think it's looking for a process that has been opened by proc_open but i am not able to get the syntax of proc_open

so help me out
i am stuck here for last 2 days :(

shoonya
Jun 18 '07 #3
Atli
5,058 Expert 4TB
I managed to get this working using the 'ipconfig' command, didn't manage to get a notepad window. Don't really undestand why you'd want that anyways.

But anyhow.. this is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. $descriptorspec = array(
  5.    0 => array("pipe", "r"),
  6.    1 => array("pipe", "w"), 
  7.    2 => array("pipe", "r")
  8. );
  9.  
  10. $process = proc_open('ipconfig', $descriptorspec, $pipes);
  11.  
  12. if (is_resource($process)) {
  13.  
  14.     // Get the proccess info
  15.     echo "Proccess information:<pre>";
  16.     $var = proc_get_status($process);
  17.     print_r($var);
  18.     echo "</pre>";
  19.  
  20.     // Print stream from proccess
  21.     echo "Process output:<pre>";
  22.     echo stream_get_contents($pipes[1]);
  23.     echo "</pre>";
  24.     fclose($pipes[1]);
  25.  
  26.     // It is important that you close any pipes before calling
  27.     // proc_close in order to avoid a deadlock
  28.     $return_value = proc_close($process);
  29.  
  30.     // Print return value (0 if success)
  31.     echo "Process returned:<pre>";
  32.     echo $return_value ."\r\n";
  33.     echo "</pre>";
  34. }
  35. else
  36. {
  37.   echo "Process failed to open";
  38. }
  39. ?>
  40.  
This is based on an example found at php.net/proc_open
Jun 19 '07 #4
shoonya
161 100+
ooops
you have just pasted the example from php.net

I was not getting the concept of pipes and streams
so any good tutorial or link will work for me

shoonya
Jun 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. ---- Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
2
by: Henrik | last post by:
Hi all, I'm working with a win app in vb that needs access to actual process id of the office-applications Word, Excel and PowerPoint. I know I can loop the processes and check for processes of...
2
by: py | last post by:
Is there a way in python to figure out which process is running on which port? I know in Windows XP you can run "netstat -o" and see the process ID for each open port....but I am looking for...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
4
by: eva.monsen | last post by:
I'm trying to run a .BAT file using System.Diagnostics.Process. I'm having trouble getting Process.ExitCode to match up with what the .BAT file returns. Here are the contents of...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
1
by: desivirus | last post by:
hi admin.. i followed your tip in "HOW TO LIST PROCESS ID IN WINDOWS" thread..and iam trying to compile this code in cygwin , $gcc -mno-cygwin process.c -o -L"psapi.lib" process.exe psapi.h...
6
by: Ashutosh Bhawasinka | last post by:
Hi, I am starting a process and I need to monitor it (wait and check if its still responding). But, I it seems that the Process.HasExited or Process.Exited doesn't work. I just need to know...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.