Python:SyntaxError: invalid syntax

#!/usr/bin/python

import pexpect
import shutil
import os
import stat

remote_dir=r'/quest/splex-builds/depot/spo/9.0.1/latest/'
local_dir=r'/splex/'
tmp_file=r'/splex/tmp.txt'

file_head=r'SharePlex-9.0.1-b'
file_tail=r'-oracle110-rh-40-amd64-m64.tpm'

user = 'qarun'
ip = '127.0.0.1'
mypassword = 'qarun'

child = pexpect.spawn('ssh %s@%s' % (user, ip))
child.expect('password:')
child.sendline(mypassword)
child.expect('#')
for (p, d, f) in os.walk(remote_dir):
for i in f:
if i.startswith(file_head) and i.endswith(file_tail):
if os.path.exists(i):
child.sendline(local_dir+i|tee -a tmp_file)

[qarun@zh11gtm03:/splex]$./upgrade.py
File "./upgrade.py", line 30
child.sendline(local_dir+i|tee -a tmp_file)
^
SyntaxError: invalid syntax

在最后的这行代码中,我想要实现执行这个命令的同时,将这个命令打印出来的代码都放到tmp_file里面,这个功能该如何实现呢?

查看全部
jwcandy
jwcandy
2017/08/21 03:49
  • python
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复