I've got a list of hosts that I'm trying to iterate over for a ssh connection. In ruby I can use #{variable} to access a the variable within a command, what should I be doing for python?
I've included the ruby syntax in the following python code as a placeholder of where I'd like the functionality. What is the pythonic way of doing this?
h = """
foo-pants-linux-001
foo-pants-linux-002
foo-pants-linux-003
foo-pants-linux-004
foo-pants-linux-005
"""
hosts = h.split()
for host in hosts:
subprocess.check_output("ssh foobar@#{host} `echo hi!`")