Another request for comments on beginner code

Jeffrey Templon (templon@paramount.nikhefk.nikhef.nl)
Fri, 4 Mar 1994 14:12:01 +0100 (MET)

Hi,

I thought it was a good idea to send 'newbie code' to the
list for criticism, as a previous poster did - the newbies
will undoubtedly pick up the snaky way to do things in this
fashion.

So here is my first python program, much less impressive
than the last one sent in. Its purpose is to do 'ps'
on a remote machine, filter out all the root processes,
and print part of the info (memory and CPU usage, person,
and command name) as output.

#
# rps.py - remote ps script
# prints owner, size, CPU time used, and command name
#
# give as first argument the remote machine name
#
import regsub, os, sys

string = 'rsh '+ sys.argv[1] + ' ps uax | grep -v root'

psfile = os.popen(string,"r")
lines = psfile.readlines()

for i in range(0,len(lines)):
lines[i][:10] + lines[i][24:30] + ' ' + regsub.sub('\012','',lines[i][50:])

psfile.close()

Comments welcome.
JT