0
一個腳本部分的目標是週期性地連接到主機範圍和rsync某些日誌回中央服務器工作完美無缺手動調用它時,的Cron - 失敗調用外部腳本(環境變量初始化)
python ./apex2zabbix.py --sync="Client_Service_Platform Emtity"
然而,通過cron的調用時,模具與遠程rsync的步驟的.EOF,
command = "/usr/bin/rsync -e ssh -a %s --compress=9 -pgtov %s %s --exclude='*' %[email protected]%s:%s%s %s" % (remote_rsync_binary, excluded_expression, filters_expression, user, ip, source_path, file_filter, target_path)
p = pexpect.spawn(command, timeout=360)
i = p.expect([ssh_new_conn,'[pP]assword:',pexpect.EOF])
print 'Initial pexpect command output: ', i
if i == 0:
# send 'yes'
p.sendline('yes')
i = p.expect(['[pP]assword:',pexpect.EOF])
if i == 0:
# send the password
p.sendline(passwd)
p.expect(pexpect.EOF)
elif i == 1:
# send the password
p.sendline(passwd)
p.expect(pexpect.EOF)
elif i == 2:
print "key or connection timeout"
pass
返回
Initial pexpect command output: 2
可能是什麼原因造成的? 感謝