Skip to content

Instantly share code, notes, and snippets.

@clowwindy
Created June 28, 2012 12:57
Show Gist options
  • Save clowwindy/3011218 to your computer and use it in GitHub Desktop.
Save clowwindy/3011218 to your computer and use it in GitHub Desktop.
psudo
import os
import sys
import getpass
import subprocess
password = getpass.getpass('input password:')
for line in open('server_list.txt'):
line = line.strip()
print line
os.system('scp init_directory.sh %s:~/' % line)
s = subprocess.Popen(['ssh', line, "sudo", "-S", "bash", "init_directory.sh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
s.stdin.write(password+'\n')
s.stdin.flush()
out, err = s.communicate(password)
print out
print err
s.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment