Good find. USERPROFILE is undefined from Apache because it runs as a service, not from user Windows session.
However, both it and HOME can be set in jhp.cmd alongside PATH_TRANSLATED. Alternative to URL Rewrite could be ScriptAliasMatch, which may better preserve requested URL. Also instead of %SCRIPT_NAME% another variable may work. > From: "Sherlock, Ric" <[email protected]> > > I had a go at trying to get Apache to work on Windows without cygwin. > > I think one issue that may be causing problems is that Apache doesn't set the > USERPROFILE environment variable in the session. The result is that during > the > starting of the J session the noun "home" in profile.ijs gets the value of 0 > which causes a domain error at: > user=. home,userx > > I checked the IIS USERPROFILE setting and patched my profile.ijs with the > following to give a similar result for Apache: > > home=. >(systype-5){(2!:5'HOME');(2!:5'USERPROFILE');'\My Documents' > home=. 'C:\Windows\system32\config\systemprofile'"_^:(0 -: ]) home > userx=. '\j',('64-'#~16={:$3!:3[2),'602-user' > user=. home,userx > > By using the following jhp.bat (instead of jhp.sh) > > Rem ============ jhp.bat =================== > @echo off > rem set PATH_TRANSLATED=C:%SCRIPT_NAME% > set > PATH_TRANSLATED=C:/users/rsherloc/documents/web/jhp/htdocs/examples/testrgs.jhp > "C:\program files\j602\bin\jconsole.exe" web/jhp/run %* > Rem ======================================== > > and commenting out the "exit 0" at the end of web/jhp/run.ijs I was able to > verify that my script (testrgs.jhp) ran successfully and gives what looks > like > the desired output. > > NB. ===== output from testrgs.jhp copied from jconsole session =========== > Content-Type: text/html > > J Test > > > > Welcome to JHP > > > C:/users/rsherloc/documents/web/jhp/htdocs/examples/testrgs.jhp > > SERVER_SOFTWARE : Apache/2.2.11 (Win32) > SERVER_NAME : localhost > GATEWAY_INTERFACE : CGI/1.1 > SERVER_PROTOCOL : HTTP/1.1 > SERVER_PORT : 80 > REQUEST_METHOD : GET > REQUEST_URI : /jhpexapache/testrgs.jhp?one+two+three > PATH_INFO : > PATH_TRANSLATED : > C:/users/rsherloc/documents/web/jhp/htdocs/examples/testrgs.jhp > SCRIPT_NAME : /cgi-bin/jhp.bat > SCRIPT_URI : > SCRIPT_URL : > QUERY_STRING : one+two+three > REMOTE_HOST : > REMOTE_ADDR : 127.0.0.1 > AUTH_TYPE : > REMOTE_USER : > REMOTE_IDENT : > CONTENT_TYPE : > CONTENT_LENGTH : > HTTP_ACCEPT : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > HTTP_USER_AGENT : Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1) > Gecko/20090616 Firefox/3.5 (.NET CLR 3.5.30729) > USERPROFILE : > CGIPATH_j_ : C:/users/rsherloc/documents/web/jhp/htdocs/examples/testrgs.jhp > ~home : C:\Windows\system32\config\systemprofile > ~user : C:\Windows\system32\config\systemprofile\Documents\j602-user > > > > NB.===========end output =========================================== > > However I still have to resolve the following issues: > * I need to dynamically set PATH_TRANSLATED from SCRIPT_NAME (PowerShell > looks > promising here). > * SCRIPT_NAME is set as "/cgi-bin/jhp.bat" not the path to the script from > the > browser. (could use base of REQUEST_URI instead) > * I still get an Internal Server error from the above script (works fine > from > same file/folder in IIS) > > > > -----Original Message----- > > From: Oleg Kobchenko > > > > This is a good tip. Since it's hard to figure out how > > to run any CGI on Apache for Windows: > > #!scripts > > if you don't have /bin/sh and it's not clear how to run > > a cmd script. One venturing on Apache on Window must realize > > the consequences. > > > > The following J script runs from command line, but gives > > an error under Apache (same drive where Apache installed): > > > > =============================================================== > > #!/j602/bin/jconsole > > > > echo_z_=: 0 0&$@(1!:2&2) > > > > echo 'Content-Type: text/plain',LF,LF > > > > echo 'Hello from J',LF,LF > > > > exit '' > > =============================================================== > > > > Error Log: > > [error] malformed header from script. Bad header=|domain error: > > test.ijs > > > > You could configure: > > ScriptInterpreterSource Registry-Strict > > and a registry key > > Shell\ExecCGI\Command > > > > Anyway first the above script should run, then you need to resovel > > PATH_TRANSLATED env variable. > > > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
