Question

I want to ssh to another node on my network as part of a larger python script, I am using pexpect which works when I do something like this:

session=spawn('ssh root@172.16.210.254')

I want to replace the address with a variable so I can cycle through addresses in a list however when I try:

address = "172.16.210.253"

session=spawn('ssh root@'address)

It doesn't work as using address in this way is invalid syntax. What is the correct syntax for this?

Was it helpful?

Solution

session=spawn('ssh root@' + address) to concatenate the strings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top