system call

sharyn's picture

They have: 18 posts

Joined: Aug 2004

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 Smiling

- sharyn

sharyn's picture

They have: 18 posts

Joined: Aug 2004

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 Laughing out loud

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.