Created
June 28, 2012 12:57
-
-
Save clowwindy/3011218 to your computer and use it in GitHub Desktop.
psudo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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