Hello! I wrote a litle program that send commands to many cluster nodes: #!/usr/bin/env python #By: Djames Suhanko
#servers list sincroniza =["server1.domain","server2.domain", "server3.domain"] import pexpect import sys from threading import Thread #the user and pass can be in ini file. #Test parameters list try: if sys.argv[3]: pass except: print "Use: " + "script" + " <command> <user> <pass>" sys.exit() #This function send the command in argument def executor(command,username,password,server): a = 'ssh ' + username + '@' + server foo = pexpect.spawn(a) foo.expect('.*ssword:') foo.sendline(password) foo.sendline('su') foo.expect('.*sword:') foo.sendline('root_password_here') foo.sendline(command + '&& exit') print "command to: " + server + "..........[OK]" foo.sendline('exit') foo.expect('.*osed.') foo.interact() #make a list tasks = [] #theading loop for i in sincroniza: t = Thread(target=executor,args=(sys.argv[1],sys.argv[2],sys.argv[3],i)) t.start() tasks.append(t) #wait the end for t in tasks: t.join() it's all! On Wed, Jul 8, 2009 at 9:15 AM, Hendrik van Rooyen<m...@microcorp.co.za> wrote: > "Hussein B" <hubaghd...@gmail.com> wrote: > >> Hey, >> I want to perform commands on a remote server over SSH. >> What do I need? >> Thanks. > > Access privileges for the remote machine. > > - Hendrik > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Djames Suhanko LinuxUser 158.760 -- http://mail.python.org/mailman/listinfo/python-list