Get a list of currently running processes?

UPDATE: So far I have:

set (procs) to (do shell script "ps -c -U USER")

Replace USER with your usrname and run. It outputs what ps would output, but it only shows the processes for the user specified, which is what I want. But I need to figure out a way to strip away all the information except for the command name (in the far right column).

I want to write a script for school exams. This is what it is going to do:

  1. When run, the script gets a list of currently running processes and stores them in memory.
  2. Preiodically, the script gets a new list of currently running processes and checks them against those in memory. If it finds new proccesses, it checks them against a list that is has stored in the actual script of programs that can be opened. If the new proccesses do not match up with the list of permitted applications, the program does something (maybe send a message to the administrator over ARD or something).

I’m not worrying about what the program does when it finds a new application that’s not on the list has been opened. I just don’t know how to do two things:

  1. Get a list of currently running processes (is there a way to output the terminal command ps to applescript’s memory?
  2. Take the list of processes and turn them into an array that can be compared to another array to looke for changes.

If anyone has any idea on how to do any part of this, please let me know. When I’m done with the script I’ll post the full code here as well for anyone who would like to use it.

  • Black Leopard

P.S. I know OSX has parental controls, but this script would be much easier to run over ARD then to have to sit down at every computer and reconfigure it for exams.

Model: Powerbook G4
AppleScript: 2.1.1 (81)
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

And when some kid quits/force-quits your script? You should lock the machines down to just the applications you want them running.

The clever bit is that when they go to open that application, it will automatically be quit, as it won’t be on the safe applications list. The idea is that during an exam, when we do not wish students to be using the internet or an email client, we can just run this script. Students are allowed to do whatever they like (within reason) on our computers, but during exams we do not want to make it easy for them to cheat.

If you have a script looping to check for processes–recall that you said you wanted a script that checked periodically–and I quit the script, you have lost all control over what I can and cannot do.

Set up managed accounts for exam time. That is the correct solution. You may even be able to do this with ARD3.

Edit: Even if you run it remotely, what about between runs? You’re chasing a mouse through a box factory. Lock 'em down for real or don’t bother.

I concede to your point. Oh well.