简体   繁体   English

python cgi将不会加载

[英]python cgi won't load next

I wrote a cgi script that will open a firefox window using os.system("firefox &") . 我编写了一个cgi脚本,它将使用os.system("firefox &")打开一个firefox窗口。

So the idea is that it'll make a firefox window for me, and then print a confirmation page for the remote user. 因此,其想法是它将为我创建一个Firefox窗口,然后为远程用户打印确认页面。

The problem is that it only prints the confirmation page after I close the firefox window. 问题是它仅在我关闭Firefox窗口后才打印确认页面。 This is especially puzzling because if I run the script in terminal as opposed to letting apache run it, it prints the confirmation html right away like it is supposed to. 这尤其令人困惑,因为如果我在终端中运行脚本而不是让apache运行它,它会立即像预期的那样打印确认html。

Can anyone offer any insight as to why I am having trouble loading the confirmation page immediately? 关于我为何无法立即加载确认页面的原因,有人可以提供任何见解吗?

don't use os.system . 不要使用os.system Use subprocess module . 使用subprocess模块

os.system documentation says: os.system文档说:

The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; 子流程模块提供了更强大的功能来生成新流程并检索其结果。 using that module is preferable to using this function. 使用该模块优于使用此功能。

Try this: 尝试这个:

subprocess.Popen(['firefox'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM