A problem with commands.getoutput

I am wondering why I see the following error when running a Python script
with the following contents:

import commands
s  = commands.getstatusoutput("uptime")

The error is

$ sh: -c: line 0: syntax error near unexpected token `2′
sh: -c: line 0: `{ uptime; } 2>&1′

Test on my 2.6.4 does not emit the error. Maybe the 2.5.4 version of commands module is buggy?

If all we want is the load average, one can read off the information from /proc/loadavg or simply use the os.getloadavg() function. These do not entail using an intermediary terminal, whether visible or not.

  • Share/Bookmark

Leave a Reply

Digital explorations is Digg proof thanks to caching by WP Super Cache