I am writing a Folding@Home desklet. I couldn't think of a
cool way to represent the data so I'm simply cloning the
SuperKaramba
folding theme. So far it's complete but that shows the
pid, I'm assuming of the parent process. I could use statgrab
but then it's an extra dependency for something simple like
that, it hardly seems worth it...
That is the reason I wanted to use something unix-friendly. I
wans't aware that pidof was generally a root-only thing, it
isn't in Arch Linux which I use :oops: I'll give your
solution a shot and see how it goes, thanks for the advice
:D
EDIT:
Okay, it works fine when I paste the command straight into a
terminal but not in my script and I don't know why. Basic
commands like
whoami work fine, I
can't see where I messed up.
def _shell(cmd):
try:
output = os.popen('%s 2>/dev/null' % cmd).read()
except:
_dPrint('Error reading data from command line')
return output
print _shell("ps -A | sed -n '/FAH502\-Linux\.ex/{s/^[ \t]*\([0-9]\+\).*/\1/;p}'")
That prints nothing but blank line, but at the terminal it
displays the pid as it should :(