[Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread Charlie Reddington
Hi, I'm very very green when it comes to python. I know bash better than python, so I figured a good way to learn things was covert my bash stuff to python. So here goes... Here's a quick example of the code I have that is broken. import os username = 'charlie' private_key = '/path/to/key

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread Charlie Reddington
arlie' private_key = '/path/to/key' ssh = '/usr/bin/ssh' command = 'hostname && df -h && exit' servers = ['172.16.1.1', '172.16.12.2', '172.16.1.3'] for host in servers: os.system("ssh %...@%s -i %s

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread Charlie Reddington
On Jun 23, 2009, at 4:50 PM, Alan Gauld wrote: "Charlie Reddington" wrote Your code works as expected! Can you tell me what your code is doing different than mine? os.system needs the command to be a string so you have to build up the string by passing in your variables using