使用PHP运行python脚本的输出。Exec、PASSTRU和系统给出错误“;找不到终端“;
我尝试使用exec从php正常运行python脚本,但它提供:使用PHP运行python脚本的输出。Exec、PASSTRU和系统给出错误“;找不到终端“;,php,python,terminal,output,Php,Python,Terminal,Output,我尝试使用exec从php正常运行python脚本,但它提供: curses.wrapper(curses_loop) [5] => File "/opt/python27/lib/python2.7/curses/wrapper.py", line 22, in wrapper [6] => stdscr = curses.initscr() [7] => File "/opt/python27/lib/python2.7/curses/__
curses.wrapper(curses_loop) [5]
=> File "/opt/python27/lib/python2.7/curses/wrapper.py", line 22, in wrapper [6]
=> stdscr = curses.initscr() [7]
=> File "/opt/python27/lib/python2.7/curses/__init__.py", line 33, in initscr [8]
=> fd=_sys.__stdout__.fileno()) [9]
=> _curses.error: setupterm: could not find terminal
python脚本是一个在终端上运行良好的程序。这是一个货币图表,外汇等与许多选项的程序。
我认为问题在于程序使用终端来正常工作,并且不能在输出(stdout等)上模拟这种情况
我还尝试将wrapper.py更新为,但失败了。错误再次发生
我也尝试过,在终端export TERM=xterm new
或export TERM=xterm-256color
中,但再次失败
我被卡住了,如果可能,请帮助我。这是我的python脚本中的代码部分:“if secret.prompt_decrypt()!”secret.S_FAIL_致命:curses.wrapper(curses_loop)“”。这是运行python脚本的php代码的一部分:“exec(“python myscript.py 2>&1”,$some_var);”。好吧,假设您的PHP脚本是从Web服务器运行的,而Web服务器通常没有控制tty,因此您不能(轻松地)从它派生一个基于curses的进程。您想在这里实现什么?@PbB您是否尝试过使用
系统
、shell\u exec
或passthru
(具有完整路径)?谢谢您的帮助。塞勒姆先生,我尝试了“系统”、“shell_exec”和“passthru”的完整路径,但没有成功。根本没有输出,什么也没有。我想对我的python脚本程序做一点描述。这不是一个只输出“hello world”之类内容的小脚本。当它开始时,它是一个货币交易系统。它有一个屏幕来查看图表,它有键盘快捷键,它有登录等等。所以,我想我需要改变我的问题,是否可以将它输出到具有所有功能的浏览器。我想这回答了你的问题(阿雅:)我也尝试了python子进程'sub#/usr/bin/env python import subprocess import sys child=subprocess.Popen(“python~/full path to my script/myscript.py”,shell=True,stderr=subprocess.PIPE),而True:out=child.stderr.read(1)if out==”和child.poll()无:如果发生则中断!='':sys.stdout.write(out)sys.stdout.flush()'错误相同:'\u curses.error:setupterm:找不到终端'