I have a working basic cgi bash script using lighttpd. This is working:
#!/bin/bash
echo -e 'Content-type: text/html\n'
echo '<html>'
echo '<head>'
echo '<title>test</title>'
echo '</head>'
echo '<body>'
echo "Hello World"
echo '</body>'
echo '</html>'
The problem is if I try to add some kind of conditional... it doesn't work. If you change only the hello world line for this:
if [ 1 -eq 1 ]; then
echo "it worked"
else
echo "anything else"
fi
It shows nothing. I tried to put them all in one line:
if [ 1 -eq 1 ]; then echo "it worked"; else echo "anything else"; fi
Same result. It shows nothing.
I have a "trick" which works but is not an option to me... long to explain. It's using something like this:
[[ 1 -eq 1 ]] && echo "it worked"
Any idea about what can be happening? If anybody needs more data, or lighttpd.conf or whatever just tell me. Thanks.
The solution is as simple as changing the line feeds of the end of lines from CRLF to LF on the file. This happens when using Windoze.