Reputation: 361
I'm trying to run my jscript files and return result to client using CGI. But I can't to set first line og mys cript like #!/usr/bin/cscript.exe because jscript not support comments started by # and get error.
Question: How can I set path to my CGI interpreter without !#/usr/bin/cscript.exe in the first line of my script?
Upvotes: 0
Views: 283
Reputation: 38755
From my rather dated httpd.conf:
# However, Apache on Windows allows either the Unix behavior above, or can
# use the Registry to match files by extention. The command to execute
# a file of this type is retrieved from the registry by the same method as
# the Windows Explorer would use to handle double-clicking on a file.
# These script actions can be configured from the Windows Explorer View menu,
# 'Folder Options', and reviewing the 'File Types' tab. Clicking the Edit
# button allows you to modify the Actions, of which Apache 1.3 attempts to
# perform the 'Open' Action, and failing that it will try the shebang line.
# This behavior is subject to change in Apache release 2.0.
#
# Each mechanism has it's own specific security weaknesses, from the means
# to run a program you didn't intend the website owner to invoke, and the
# best method is a matter of great debate.
#
# To enable the this Windows specific behavior (and therefore -disable- the
# equivilant Unix behavior), uncomment the following directive:
#
#ScriptInterpreterSource registry
So I enabled the ScriptInterpreterSource feature, checked:
ftype JSFile
JSFile=%SystemRoot%\System32\CScript.exe "%1" %*
and used c:\programme\xampp\cgi-bin\jscgi.js
containing:
WScript.Echo("Content-Type: text/html\n");
WScript.Echo("OK:", WScript.ScriptFullName, new Date());
successfully. I did not touch other settings like AddHandler, directory, or ScriptAlias, and I just tested phpinfo.php and printenv.pl to see if this change wrecked my installation blatantly - no.
You should be much more prudent.
Update wrt comment:
According to the 2.4 docs (search for "ScriptInterpreterSource") the directive is still valid. Are you sure the apache user account associates .js files with cscript.exe?
Upvotes: 1