Python SSH and comparing output to an imported list
<p>I am looking to ssh to multiple servers 1 at a time , compare the output of an ssh command to a list, and then run a command on the items in that appear in both the output and a separate list.</p>

<p>I'd like to ssh to each server in a loop "ssh  " but I'm unsure how to import the next server from the list into the middle of the ssh command.</p>

<p>The other issue I'm having is obtaining the results of a command run which I could then compare.</p>

<p>Any guidance or direction to a helpful post would be fantastic.<br>
Thank you!</p>

<p>The answer to your question if I understood correctly lies in Operative Systems principles,</p>

<p>You iterate the SSH connection list, and by using Popen you are able to SSH via Shell.</p>

<p>After that you need to keep a second process open as well a Pipe for the 2 processes to communicate(the one that opened the ssh via shell, this one is blocked in IO) and use the second process to make verification etc and send new commands via PIPE created by the first process. PIPE.STDIN</p>

<p>In short, check Popen Python Module.</p>

<p><a href="https://docs.python.org/2/library/subprocess.html" rel="nofollow">https://docs.python.org/2/library/subprocess.html</a></p>

python list loops ssh