How to configure CGI on IIS 7? - iis

I did this
http://reboltutorial.com/images/rebol-iis.png
as explained here but it was for IIS 6
http://rebolforum.com/index.cgi?f=printtopic&topicnumber=39&archiveflag=new
I also activated 32 bits for application pool as explained here
http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx
But when browsing to the test script it doesn't work, seems to take forever showing nothing, then in the end shows this message error:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
I used a dedicated server on windows 2008
Source code of the test script:
REBOL [Title: "Cgi Test in Rebol"]
print "HTTP/1.0 200 OK^/Content-type:text/html^/^/";
print []
print ["Date/time is:" now]
print []
Should I ask on serverfault rather as nobody seems to know here ?

Finally I got my answer, here are the steps:
Open Server Manager from Administrative Tools.
Add role "Web Server (IIS)"
Try http://localhost/ from your browser. You should see the IIS7 Welcome Page.
Copy core.exe to c:\ (or somewhere else), right click on core.exe and open Properties window, give Read & Execute access to IUSR_xxxx under Security tab. (If you've any problem, try to give Read & Execute for Everyone)
Open "Internet Information Services (IIS) Manager" from Administrator Tools.
Click on Default Web Sites, double click on Handler Mappings, click on Add Module Mapping from the right panel and type the followings:
Request Path: *.r
Module: c:\core.exe -cs %s %s
Name: Rebol
Select Yes when Add Script Map dialog box appears. It will add the c:\core.exe -cs "%s %s" as allowed under ISAPI and CGI Restrictions list.
Create a test.r file under wwwroot folder. My test.r file contains following script:
R E B O L [Title: "Server Time"]
print "content-type: text/html^/"
print [<HTML><BODY>]
print ["Date/time is:" now]
print [</pre></BODY></HTML>]
And type http://localhost/test.r on your browser.
If everything goes well then it should work.
If you are trying with View.exe then you may need to put --noinstall to command line, otherwise when View start with IUSR_xxx user account it will open desktop & installation window and it stays background (you can see it from Task Manager).
c:\view.exe -csi %s %s
You may also need to put double quotes around %s if your script is in a path with spaces. Use the following form:
c:\core.exe -cs "%s %s"
Instead of this:
c:\core.exe "-cs %s %s" (<-- this won't work!)
I hope this will help.
UPDATE: I've faced a problem on IIS6 (Windows 2003 Server), it gives 404 when I configure it as follow (it works on IIS7 as told above):
c:\core.exe -cs "%s %s"
But it runs as:
c:\core.exe" -cs "%s" %s
Here is the link for Perl installation.
http://www.howtogeek.com/50500/how-to-install-perl-on-iis-6-for-windows-server-2003/

Related

running SALOME in windows 10 gives "Can't find a free port" error

I'm trying to run SALOME GUI using run_salome.bat. GUI doesn't start and gives "Can't find a free port to launch omniNamesTry to kill the running servers and then launch SALOME again." error.
SALOME version 9.4
Windows 10
I have searched the files in C:\Users<username>\AppData\Roaming that contain "omniORB_PortManager" in their name and deleted them.
Here the issue can be resolved be removing several files generated by SALOME.
start a Windows file browser
in the search bar, type: %userprofile%\.config\salome
delete all files present in that directory
in the search bar, type: %APPDATA%\salome
remove all files present in that directory
in the search bar, type: %APPDATA%
delete all files wich name starts with: .omni
delete file: .salome_PortManager.cfg
Finally, I strongly suggest to raise such questions directly on SALOME forum at this link

IIS appcmd called via Go app - Invalid XML input

I have this command, which works when running in command line directly.
import "os/exec"
...
out, err := exec.Command("cmd", "/C", `%windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`).Output()
When I run it via Go app, it throws exit status 3222072890 with this error message:
Failed to process input: Invalid XML input - please make sure that your XML is well-formed and follows the required format (HRESULT=c00cee3a).
I've already tried to change slashes, use various quotation marks, but still does not work.
I use IIS 8.5 on Windows Server 2012 R2.
It seems that command is corrupted before execution. Is there any way how to see the output command?
It seems to be a bug in golang library - related to a Golang Github issue #15566.
Issue is caused by quotation marks in /site.name argument ("My website") which are escaped, but should not be.
Solution for this time is this:
import "os/exec"
import "syscall"
...
cmd := exec.Command(`cmd`)
cmd.SysProcAttr = &syscall.SysProcAttr{
CmdLine: `/C %windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`,
}
out, err := cmd.Output()
For more information see: http://www.josephspurrier.com/prevent-escaping-exec-command-arguments-in-go/ and exec with double quoted argument
I just deleted all carriage returns in xml
and removed Tag
.
And
appcmd add apppool /in < C:\Installs\AppPool.xml
worked for me.

Unable to run python cgi scripts using CGIHTTPRequestHandler in Python 3.3

I am a noob; trying to create and use a simple webserver in Python that executes CGI scripts written in Python. I am using Windows XP and Python v3.3.0. I have a "myserver" directory which contains "myserver.py","sample.html" and the directory "cgi-bin" which in turn contains "cgi_demo.py"
myserver.py
from http.server import HTTPServer
from http.server import CGIHTTPRequestHandler
port = 8080
host = '127.0.0.1'
server_address = (host,port)
httpd = HTTPServer(server_address,CGIHTTPRequestHandler)
print("Starting my web server on port "+str(port))
httpd.serve_forever()
cgi_demo.py
import cgi
import cgitb; cgitb.enable()
print("Content-type: text/html")
print
print("<html><body>")
for i in range(0,100):
print(i,"<br>")
print("</body></html>")
Now the directory listing works fine for "myserver" but not for "cgi-bin"; maybe that is how it is coded - I don't have a problem here. "sample.html" is retrieved fine too. However, the execution of "cgi_demo.py" is not proper. I get a blank page in the browser; and the console window (which is blank too) appears and disappears. Moreover, on the server's console I get the message
127.0.0.1 - - [29/Nov/2012 12:00:31] "GET /cgi-bin/cgi_demo.py HTTP/1.1" 200 -
127.0.0.1 - - [29/Nov/2012 12:00:31] command: C:\Python33\python.exe -u "D:\python apps\my web server\cgi-bin\cgi_demo.py" ""
127.0.0.1 - - [29/Nov/2012 12:00:32] CGI script exited OK
Please tell me what is wrong! I get the feeling that the output stream of my script is not connected to the server. What am I doing wrong? Don't say that I have to extend CGIHTTPRequestHandler!!
SORRY for the trouble!
Well, it is my fault. 2 things to note:
[1]The console window that appeared and disappeared; it only happens when I use IDLE to execute the server. If the script is already running in a normal windows console then this does not happen. My Feeling was WRONG.
[2]There is an bug/error in my cgi script. After printing the HTTP header; the print statement that I wrote was just "print" instead of actually being "print()".This is so embarrassing! But, even then why didn't the interpreter catch this error?

How to remove multiple virtual directories?

I need to remove a big amount of virtual directories, some of them don't have associated physical directories.
Ideas?
As you need to remove a large amount, I'm guessing you'll want to use some form of script.
IIS 6.0, using IISvdir.vbs( article # MSDN):
At the command prompt, use the cd command to change to the directory where the Iisvdir.vbs script is installed. The default location for this file is systemroot/system32/iisvdir.vbs.
At the command prompt, type:
cscript iisvdir.vbs /delete "Sample Web Site" VirtualDirectoryName.
Substitute your Web site name and virtual directory name as appropriate. If there are spaces in the Web site name, use quotation marks around the Web site name, as shown in the preceding example.
IIS 7 using AppCmd.exe (article # TechNet):
To remove a virtual directory, use the following syntax:
appcmd delete vdir /vdir.name: string
The variable vdir.namestring is the virtual path of the virtual directory.
For example, to remove a virtual directory named photos from the root application of a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name: contoso / photos
To remove a virtual directory named photos from an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name: contoso / marketing / photos
HTH
You could also write an msbuild script to do this and use the msbuild extension pack which is available here. I have used this successfully to do exactly what you are saying for 100s of vdirs in iis 6 AND in iis 7.5.
Its pretty simple and took me longer to write the .proj file than it did to figure out how to do it.
have fun :)
the resultant msbuild target would look like as follows
<Target Name="IIS7VirtualDirectories:Delete">
<MSBuild.ExtensionPack.Web.Iis7Application
TaskAction="Delete"
Website="%(Application.WebsiteName)"
Applications="#(Application)"
MachineName="$(MachineName)"
ContinueOnError="false"/>
<MSBuild.ExtensionPack.Web.Iis7Website
TaskAction="DeleteVirtualDirectory"
Name="%(VirtualDirectory.WebsiteName)"
VirtualDirectories="#(VirtualDirectory)"
ContinueOnError="false"
MachineName="$(MachineName)"/>
</Target>
Where Application and VirtualDirectory are defined in an external proj file :)

How to configure catch-all in Exchange2010 hub-transport environment?

This link is explaining how to do it in an edge transport environment, indicating that it is not relevant for hub-transport.
http://technet.microsoft.com/en-us/library/bb691132(EXCHG.80).aspx
do you know what is the way to get it done in hub-transport environment?
You need to use the CatchAllAgent on CodePlex. This was written to work with Exchange 2007 but it does work with 2010 as well.
The key trick is to install it in the TransportRoles directory as per these links:
http://catchallagent.codeplex.com/discussions/218519?ProjectName=catchallagent
http://catchallagent.codeplex.com/discussions/62204?ProjectName=catchallagent
1) download the ZIP
2) unzip to "C:\Program Files\Microsoft\Exchange Server\TransportRoles\agents\catchall"
[or wherever the TransportRoles\agents path is]
3) Edit the config.xml file in this directory to define the domains to be handled
4) Run Exchange Management Shell end execute these commands:
install-transportagent -Name "CatchAll Agent" -TransportAgentFactory:CatchAll.CatchAllFactory -AssemblyPath:"C:\Program Files\Microsoft\Exchange Server\TransportRoles\agents\catchall\CatchAllAgent.dll"
get-transportagent
enable-transportagent "CatchAll Agent"
net stop MSExchangeTransport
net start MSExchangeTransport
5) Send some test mails to see if it works!

Resources