我正在尝试将此脚本写入我的linux终端,我收到以下错误消息:"OSError:[Errno 2]没有这样的文件或目录".任何人都可以帮忙,谢谢
#!/home/build/test/Python-2.6.4
import os, subprocess
# Create a long command line
cmd =[\
"si createsandbox --yes --hostname=be", \
" --port=70", \
" --user=gh", \
" --password=34", \
" --populate --project=e:/project.pj", \
" --lineTerminator=lf new_sandbox"\
]
outFile = os.path.join(os.curdir, "output.log")
outptr = file(outFile, "w")
errFile = os.path.join(os.curdir, "error.log")
errptr = file(errFile, "w")
retval = subprocess.call(cmd, 0, None, None, outptr, errptr)
errptr.close()
outptr.close()
if not retval == 0:
errptr = file(errFile, "r")
errData = errptr.read()
errptr.close()
raise Exception("Error executing command: " + repr(errData))
Run Code Online (Sandbox Code Playgroud)
如果错误在您的脚本中,可能是您在此行上出错
errptr = file(errFile, "r")
Run Code Online (Sandbox Code Playgroud)
你可以这样做
if os.path.exists(errFile):
errptr = file(errFile, "r")
errData = errptr.read()
errptr.close()
raise Exception("Error executing command: " + repr(errData))
Run Code Online (Sandbox Code Playgroud)
并且还尝试使用fullpath来命令"si" /usr/bin/si而不仅仅是si
| 归档时间: |
|
| 查看次数: |
18131 次 |
| 最近记录: |