Forum Moderators: coopster

Message Too Old, No Replies

system call

         

sharyn

7:04 pm on Oct 27, 2004 (gmt 0)

10+ Year Member



I am on a Mac OS X server and I am trying to one of two things... if I can get either one to work I'd be happy.

First, I'm trying to do a system call to get the running processes. Doing a "ps -cx" in PHP give me a different set of processes than when I type it into the terminal window. I need the set that is returned in the terminal window. I also need to redirect it into a file so I can see if the process I want is running since I don't think I can check the output of the system call in the PHP script.

Second, if I can't get the proper set of processes back using a php system call I can run a simple C program that can do it, but I can't seem to call the C program from PHP.

Here is the code I've testing with :


system("ps -cx"); echo "<br>";
system("ps -cx > SystemCheckFile.txt");
system(/User/administrator/C\ Apps/SystemCall/SystemCall");

The first one echos out the processes but all I get back is a series of httpd processes.

The second one is supposed to redirect the output to the fiel SystemCheckFile.txt, but I can't find it anywhere on my computer which leads me to believe that the file is not getting creatied.

The third one calls a C program that does the same thing as the second call except when I run the program on it's own, I get all the processes that I am expecting, such as Netscape, Finder, Dreamweaver..etc...

If anyone has a suggestion, I am willing to listen :)

- sharyn

sharyn

8:29 pm on Oct 27, 2004 (gmt 0)

10+ Year Member



* SOLVED *

Solution :


do {
$PNG_running = system("ps -acux ¦ grep PNG");
} while (strlen($PNG-running) > 0)

when the PNG process stops running, I can display my PNG file :D

jatar_k

8:31 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nice, I had no clue :)