Project

General

Profile

[Solved] Lighttpd on Windows (cygwin) - mod_magnet

Added by carlos over 6 years ago

Hi,

I am using lighttpd compiled with cygwin on windows (grabbed the binaries from http://lighttpd.dtech.hu ) and I am having trouble using mod_magnet.

Basically I wanted to use a lua script (example below) to run a shell command and use its output. But probably due to some quirk related to cygwin the script can't run/find any shell command ( checking the env vars, the script is being run as if inside cygwin, which makes sense ).
As mod_magnet has no external dependencies besides lua (?), I was considering just statically compiling myself the module but without using cygwin.

Is there a easy way to compile just mod_magnet using auto tools ?
Any obvious alternative that I might be missing ?

lua script:

local handle = assert ( io.popen('dir') )
local result = handle:read("*a")
handle:close()

Cheers


Replies (2)

RE: Lighttpd on Windows (cygwin) - mod_magnet - Added by carlos over 6 years ago

Failed to realise how tightly coupled the lighttpd modules are. It is not practical to just compile one module, it is really necessary to compile all of (or most of) lighttpd.

Kind of surprised it is not just adding a main include ( lighttpd.h ) to the source file and then compiling the module like:

gcc -std=c99 -shared -O2 -o mod_mymodule.so mod_mymodule.c

Will have to retry using mod_magnet as it is (cygwin build). :/

RE: Lighttpd on Windows (cygwin) - mod_magnet - Added by carlos over 6 years ago

Unfortunately, some behaviors of the functions in Cygwin DLL depend on and are geared toward the POSIX-like environment which Cygwin provides. For instance, some aspects of the path handling will confuse Windows users. And some things don't work at all: the popen and system functions look for a system command interpreter whose path name is /bin/sh which takes a -c option.

lua uses system functions, in this case the cygwin's system functions so basically you need to have a bin/sh.

I fetched a win32 implementation of bash ( https://sourceforge.net/projects/win-bash/ ) and extracted to a /bin/sh folder in the working dir i call lighttpd. Now lua's io.popen function is working correctly.

    (1-2/2)