Forum

Variables in conf file

Cesare
2 June 2011, 10:12


Hiawatha version: 7.5
Operating System: W2k3 (cygwin)

I like the possibility to have variables in the configuration file, but i can't understand how to use this feature to avoid repeating paths.
In other words, i'd like to do something like this:

set progdir = C:\Documents and Settings\pippo\Desktop\hiawatha-7.5\
WorkDirectory = progdir + Hiawatha\work

It's possible to achieve that?

Under Windows the server seems to have the "C:\Program files" path hardcoded somewhere, because if i don't define WorkDirectory, ExploitLogfile, PIDfile, it search for them under this folder. But on my italian Windows that folder doesn't exist (it's "C:\Programmi\"), so i have to tweak several path to make the server work.

Ciao.

Cesare.
Hugo Leisink
2 June 2011, 15:56
Hiawatha does a simple search and replace for variables. There is no need for the plus sign. So, you could use the following:
set [progdir] = C:\Documents and Settings\pippo\Desktop\hiawatha-7.5\
WorkDirectory = [progdir]Hiawatha\work


Hiawatha does indeed have a hard coded "C:\Program Files". Hiawatha is build for Unix. Because Cygwin makes it so easy to make a Windows binary, I provide one. But it should only be seen as a 'nice to have'. If you want a version optimized for your OS, install Cygwin. Download the source, change extra/cygwin_config.h and do a "./configure && make win" to compile it.
Cesare
4 June 2011, 23:08
Nice trick, but looks like it doesn't work for me.

I've adapted your example to my paths:
[...]
5: set [progdir] = D:\webserver-test\hiawatha-7.5
6: WorkDirectory = [progdir]\Hiawatha\work
[...]

From an updated cygwin bash shell i obtain:
$ Hiawatha/bin/hiawatha.exe -k -c Hiawatha/config/
Using Hiawatha/config/
Reading hiawatha.conf
Syntax error in hiawatha.conf on line 6.

However i know that Windows+cygwin is not the environment for which your webserver was designed for. Just experimenting... ;-)

Keep up the good work.

Cesare.
Hugo Leisink
4 June 2011, 23:16
That error has to do with the fact that Hiawatha was designed for Unix, not Windows. Change those lines to
set [progdir] = /cygdrive/d/webserver-test/hiawatha-7.5
WorkDirectory = [progdir]/Hiawatha/work

and it should work.
Cesare
5 June 2011, 00:06
Fast as lightning!
Yes, now works.

I admit that i was not thinking about a path translation between win and cygwin, because all over the config i can use the standard Windows paths.
With my minimal C knowledge, looking at the code in serverconfig.c i guess that you parse every value associated with the "set" key, converting Win paths to cygwin. So when you do the search and replace, you generate a mixed path: windows + cygwin. Don't know if it's easy or not, but couldn't this be solved not parsing the "set" value? A sort of check that ignore the contents of the "set" key.

Hope to help and many thanks for your reply.

Cesare.
da_jojo
14 June 2011, 10:18
in windows the hiawatha webserver uses cygwin paths. you can ignore the errors cygwin spits out about the path.

Sun 12 Jun 2011 12:08:38 +0200|192.168.1.1|c:\wwwroot\site\index.php|cygwin warning:| MS-DOS style path detected: c:\wwwroot\site| Preferred POSIX equivalent is: /cygdrive/c/wwwroot/site| CYGWIN environment variable option "nodosfilewarning" turns off this warning.| Consult the user's guide for more details about POSIX paths:| http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

i tried both versions of path style , resulting in the same error. it doesnt seem to compromise the working of the webserver.
This topic has been closed.