子进程调用在shell和解释器中的作用不同

时间:2013-12-19 21:28:04

标签: python shell

当我在Python解释器中运行以下命令时,一切都很好,但在作为脚本运行时失败。不知何故,打开的隧道无法识别。任何指针都将受到赞赏。

解释

gateway = subprocess.Popen("ssh -N sshgw", shell=True)

scp_prod = "scp -r server:/NFS/{0} .".format(filePath)
subprocess.call(scp_prod, shell=True)

gateway.kill()

脚本:

try:
  gateway = subprocess.Popen("ssh -N sshgw", shell=True)

  scp_prod = "scp -r server:/NFS/{0} .".format(filePath)
  subprocess.call(scp_prod, shell=True)
finally:  
  gateway.kill()

0 个答案:

没有答案