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
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.