Quote:
I need a script that uses the ps command to display the programs which uses the CPU the most and then kill the highest one
As worded, such a script is madness.
A glance round a few sample systems which are running normally found the top CPU users to be the: disc daemon, a database engine; a background report. None of these are rogue processes. Also, on a multi-CPU system it is quite normal for a process to use 100% of one CPU.
Because there is much variation in the "ps" command, please post the exact Operating System and version you are running and what Shell you use.
Please also post a detailed tried-and-tested example of your "ps" command which identifies the faulty process(es).