I'm brand new to python, having used perl for years. A typical thing I do all the time is perl is open a command as a pipe and assign its output to a local variable for processing. In other words:
"open CMD, "$command|";
$output=<CMD>;
a piece of cake. I think I can do something similar in python this way:
args=[command, args...]
process=subprocess.Popen(args, stdout=subprocess.PIPE)
output=process.communicate()
so far so good. Now for the big question...
If I fire off that command using an ssh on multiple platforms, I can then monitor the descriptors in perl inside a select loop to process the results as they come in. I did find the python select and poll modules but am not quite sure how to use them. The documentation says poll would take a file handle, but when I try to pass the variable 'process' above to poll.register() I get an error that it must be an int or have a fileno() method. Since Popen() used stdout, I tried calling
poll.register(process.stdout)
and it no longer throws an error, but instead just hangs.
Any suggestions/pointers of how to make something like this work?