03-30-2008
You can use the popen function to get the output of the ps command.
Regards
10 More Discussions You Might Find Interesting
1. AIX
Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold
I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies
2. SuSE
Hi there,
I've install a testserver with SLES 11.0! I'll install/test XEN + WebServer not all things at the moment!
In a first time, I'd like to stop all unuse processes... but I don't understand all processes!
As someone a list of all processes with his signification and which should/could... (3 Replies)
Discussion started by: hiddenshadow
3 Replies
3. Shell Programming and Scripting
ps -xfu <user name> this command line will list all the process currently running for <user name>.
I need to filter this output. I need all the process which are running for more than 3 days(excluding demon/sys process) . The list should include PID, PPID, STIME, process/command.
I am using... (20 Replies)
Discussion started by: Sriranga
20 Replies
4. Shell Programming and Scripting
Hi All
I'm currently trying to develop a script which will find the child processes of a process ID already passed to the script.
I then need the script to look for spawned processes of these child processes and so on until it can't find any more.
For example
At the moment, I have to... (6 Replies)
Discussion started by: huskie69
6 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I need your help to understand about different processes(tty1,tty2,tty3...) running as root as shown below .What exactly these processes do?
root@bisu-desktop:~# ps -eaf | grep -e tty -e UID
UID PID PPID C STIME TTY TIME CMD
root 761 1 0 10:30 tty5 ... (4 Replies)
Discussion started by: crazybisu
4 Replies
6. UNIX for Dummies Questions & Answers
Hi:
How to list processes from all hosts, as opposed to the one you are working at?
"ps ux" appears to list processes of the user on a single host only.
Thanks.
N.B Phil (5 Replies)
Discussion started by: phil518
5 Replies
7. Solaris
Hello All
I am trying to get a list of process or applications runninging on the network only. I should emphasize that im not interested in the application or process if its not using the network.
I tried the good old netstat comand, but im not able to figure out how to list the running... (8 Replies)
Discussion started by: busi386
8 Replies
8. UNIX for Advanced & Expert Users
I am trying to kill a list of processes. I have found these two ways to list a group of process id's on a single line. How would I go about killing all of these processes all on one line?
$ ps aux | grep 6243 | grep "a.out" | awk '{printf "%s ",$2}'ps aux | grep 6243 | grep "a.out" | awk... (8 Replies)
Discussion started by: cokedude
8 Replies
9. UNIX for Advanced & Expert Users
How do I list the process in a Unix based system which are running in background?
The following are options that I'm aware of, but they may not be appropiate.
a. using ps -ef , and getting records of processes for which STATUS='S'(uninterruptible sleep)
b. using jobs -l, and filtering... (5 Replies)
Discussion started by: kumarjt
5 Replies
10. Shell Programming and Scripting
Here is the output of top command
So you see 99% of memory is in use -> Mem: 66005468k total, 65662548k used,
How can I find out all processes consuming this 99% memory in descending order of consumption i.e. starting with processes eating more memory.
I need the total of the output to... (3 Replies)
Discussion started by: mohtashims
3 Replies
POPEN(3S) POPEN(3S)
NAME
popen, pclose - initiate I/O to/from a process
SYNOPSIS
#include <stdio.h>
FILE *popen(command, type)
char *command, *type;
pclose(stream)
FILE *stream;
DESCRIPTION
The arguments to popen are pointers to null-terminated strings containing respectively a shell command line and an I/O mode, either "r" for
reading or "w" for writing. It creates a pipe between the calling process and the command to be executed. The value returned is a stream
pointer that can be used (as appropriate) to write to the standard input of the command or read from its standard output.
A stream opened by popen should be closed by pclose, which waits for the associated process to terminate and returns the exit status of the
command.
Because open files are shared, a type "r" command may be used as an input filter, and a type "w" as an output filter.
SEE ALSO
pipe(2), fopen(3), fclose(3), system(3), wait(2)
DIAGNOSTICS
Popen returns a null pointer if files or processes cannot be created, or the Shell cannot be accessed.
Pclose returns -1 if stream is not associated with a `popened' command.
BUGS
Buffered reading before opening an input filter may leave the standard input of that filter mispositioned. Similar problems with an output
filter may be forestalled by careful buffer flushing, e.g. with fflush, see fclose(3).
POPEN(3S)