现在的位置: 首页 > 综合 > 正文

python

2013年12月07日 ⁄ 综合 ⁄ 共 625字 ⁄ 字号 评论关闭

python

        


       sourcedir = 'hadoopconf.py'
        destidir  = '/home/hadoop/'
        rmipaddr  = self.getrmhost()
         user = 'root'
        passwd = 'root'
        resultscript = ''
        cmd = 'scp -r /home/yinwt/hadoop root@' + rmipaddr + ':' + destidir

def commandrun(self,hostip,cmd,user,passwd): connect=paramiko.SSHClient() LOG.debug("commandrun be called") connect.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: connect.connect(hostip,22,user,passwd) print "connectok" LOG.info(("Connected to host:%s")
% hostip) stdin,stdout,sterr=connect.exec_command(cmd) LOG.info(("Execute command success:%s") % cmd) time.sleep(2) except: LOG.debug(("Error occur when commandrun: %s") % cmd) return 'error' connect.close() return 'ok'


抱歉!评论已关闭.