I solved the problem, getting hints from Maarten. This is for posterity.
I looked at this thread:
http://www.cygwin.com/ml/cygwin/2004-09/msg01159.html
This thread (as well as Maarten) suggests to set/pass SYSTEMROOT
environment variable in Apache. I didn't know how to do that, googling
helped. This is what I did:
I added the following lines in httpd.conf
<IfModule mod_env.c>
PassEnv SYSTEMROOT
</IfModule>
Scripts are running fine now.
References:
1. http://httpd.apache.org/docs/mod/mod_env.html#passenv
2. http://httpd.apache.org/docs/env.html
Thanks again to all who replied.
Regards,
-Samik