Cygwin 上的 Lighttpd 具有与 Cygwin shell 不同的 PATH 变量

发布于 2024-11-02 11:51:11 字数 693 浏览 6 评论 0原文

我在 Cygwin 上运行 Lighttpd。我有一个 Lua CGI 脚本,它调用一个 BASH 脚本,该脚本又调用 notepad.exe。我的实际问题是运行 C# 应用程序,但我现在尝试使用记事本来简化问题。

当我调用CGI网页时,出现错误:notepad.exe:找不到命令 但是当我从 Cygwin shell 运行 BASH 时,记事本运行良好,没有错误。

看起来当 lighttpd 运行时路径正在被清理。如何确保环境相同?

CGI(LUA):

#!/usr/bin/lua

cmd = "/opt/abc/scripts/test.sh"
local f = io.popen( cmd.." ; echo RC=$?" )
assert(f)  
local str = f:read'*a'
f:close()

print ("Content-type: Text/html\n")
print ("<br><b>Output</b>: ", str)
print ("</body></html>")

BASH:

#!/bin/sh

echo "Test.sh" 
echo "<br>PATH<br> $PATH<hr>"

notepad.exe 2>&1

I'm running Lighttpd on Cygwin. I have a Lua CGI script that calls a BASH script which calls notepad.exe. My actual problem is running a C# application but I've tried to simplify the problem with notepad for now.

When I call the CGI web page, I get the error: notepad.exe: command not found
But when I run the BASH from the Cygwin shell, notepad runs fine with no error.

It looks like the Path is being cleaned when lighttpd is running. How do I make sure the environment is the same?

CGI (LUA):

#!/usr/bin/lua

cmd = "/opt/abc/scripts/test.sh"
local f = io.popen( cmd.." ; echo RC=$?" )
assert(f)  
local str = f:read'*a'
f:close()

print ("Content-type: Text/html\n")
print ("<br><b>Output</b>: ", str)
print ("</body></html>")

BASH:

#!/bin/sh

echo "Test.sh" 
echo "<br>PATH<br> $PATH<hr>"

notepad.exe 2>&1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挖个坑埋了你 2024-11-09 11:51:11

您是否尝试使用 bash -l 调用?
另外 - 在脚本中设置路径有什么问题吗?

(没有方便测试的cygwin机器)

Did you try invoking with bash -l?
also - whats wrong with setting the path in your script?

(don't have a cygwin machine handy to test)

﹏雨一样淡蓝的深情 2024-11-09 11:51:11

Lighttpd 在系统启动时由 Windows 任务计划程序启动,不需要用户登录。这意味着服务器在 Windows“会话 0”中启动,该会话被标记为非交互式。 有关 Windows 会话的更多信息

我的解决方案是抛出一个简单的批处理将文件复制到将启动lighttpd 的启动文件夹中。或者,我可以创建一个自动启动的 cygwin 服务,并确保选中与桌面交互选项。

Lighttpd was being started by windows task scheduler on system startup and didn't need a user to be logged in. This meant that the server was being started in windows 'Session 0' which is marked as non-interactive. More info on Windows Sessions

My solution was to throw a simple batch file into the startup folder that would start lighttpd. Alternatively I could have created a cygwin service that automatically starts and ensure that the interact with desktop option is checked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文