getoutput(), capturing shell command output, hostname

Returns the result of a shell command

>>> import commands
>>> a = commands.getoutput( "hostname")
>>> a
'haso107tk'

If the command output conains several lines, they can be split:

>>> import commands
>>> lines = commands.getoutput( "ls").split('\n')
>>> lines

Notice that, if a call to a sub-shell has to be protected by a time-out, it has to be done this way 15.6.5.