- 論壇徽章:
- 0
|
本帖最后由 yongsheng_2012 于 2013-07-11 18:04 編輯
寫了一個(gè)函數(shù):- def My_ssh_connect(hostname,passwd,command='',port=3562,username='root'):
- import paramiko
- paramiko.util.log_to_file('../logs/My_ssh_connect.log')
- s = paramiko.SSHClient()
- s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- try:
- s.connect(hostname=hostname,port=port,username=username,password=passwd)
- except:
- return 0
- stdin,stdout,stderr = s.exec_command(command)
- stdout = stdout.read()
- return stdout.split('\n')
- s.close()
復(fù)制代碼 另外有一個(gè)函數(shù)- def My_remove(file):
- import os
- os.remove('/tmp/%s' % file)
復(fù)制代碼 我想在My_ssh_connect函數(shù)中調(diào)用My_remove,麻煩大家?guī)兔纯茨芊駥?shí)現(xiàn),怎么實(shí)現(xiàn),謝謝 |
|