| Default User 2007-04-12, 7:23 pm |
| frikk wrote:
> Hey everyone,
> (Sorry about the first message if it made it - i got cut off
> early). I have a homework problem for my Operating Systems class. I
> am supposed to use a command such as "ps -aux" and return "N number of
> users, M number of processes". How am I to go about doing this? I am
> not very familiar with string parsing in c++, is this the only way? I
> am talking about getting the output from "ps -aux" and parsing it to
> retrieve the number of unique UIDs.
Sounds like you're working on a UNIX system. As such, the newsgroup
comp.unix.programmer is likely the best one for your question.
Some hints along the way, ps is a user command. You'll need to find a
way to capture the output that would normally be displayed by the
shell. Perhaps something like popen() will right for you. They can help
you with that there.
I've gone ahead and crossposted this to comp.unix.programmer and set
followups.
Once you solve the problem of reading the output, you may have some
programming questions that would be appropriate for this newsgroup.
Brian
|