How do you debug CGI applications under IIS

I am programming CGI applications using MS VC 7.0 that run under IIS and I need a way to debug them.  I have tried the following examples at MS http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B238788 but I cannot get them to work.  Is there an easier way to debug CGI appliations using MS VC 7.0?
marcus_careyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave_DietzCommented:
Unfortunately there really isn't.

There is no native debugger for CGI applications so you have to use the same methods you would use for any generic win32 process.

The easiest is probably the third method (Set Service Options) since it automatically starts the process under the debugger whenever it starts, but if you are using Visual Studio as your development environment it may be easier to use the Visual Studio debugger rather than WinDBG (or CDB if you're truly masochistic...).

When you say you can't get it to work what exactly are you seeing when you try?

Dave Dietz
0
marcus_careyAuthor Commented:

Dave

Here is the registry entry I am using.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\debug.exe]
"Debugger"="C:\\Debugger\\bin\\winddb"

When I access the file in the web browser, I get a HTTP 404 - File not found message.
0
Dave_DietzCommented:
This would assume your CGI is called debug.exe and your debugger is called winddb.exe and it is in the c:\debugger\bin directory.  Is this correct, and if so what is winddb (I am not familiar with this debugger...)?

How are you trying to access your CGI - what URL are you using?

What version of IIS are you running?  Can you post an entry or two from the w3svc logs showing the 404 response?

Thanks.

Dave Dietz
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

marcus_careyAuthor Commented:
Dave

The debugger is the Microsoft® Windows® System Debugger.

http://localhost/cgi-bin/debug.exe

Here is the partial log from IIS 5.0.  The last two request show the 200 response code because I deleted the registry value.

2004-11-13 14:38:37 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:41:39 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:58:22 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:58:24 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
 
0
Dave_DietzCommented:
Try downloading the Debugging Tools for Windows from the following link:

http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx

When you install them do *not* install to the default location (c:\program files\windows tool for debugging - pain in the rear to type and won't work with the registry entry due to spaces in the path).  I would suggest something more like c:\debug.

Once this is installed try using the following:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\debug.exe]
"Debugger"="C:\\Debug\\windbg"

Also, though I *strongly* doubt this has anything to do with it, you might want to rename your CGI to something other than debug.exe to avoid any possible name conflist with debug.exe in the system32 directory (another debugger of sorts).

Dave Dietz
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
meverestCommented:
Hi,

you can debug them inside the Vstudio environment by running it after setting appropriate environment variables.

All the cgi variables are passed to the executable as ENV.  for example, just "SET QUERY_STRING=action=2&next=whetever" then you can ready that data from the cgi exe as if it were running on a real live web server.  The output will go to stdout the same as any console application.

This is a much better way to debug your apps than getting iis involved.

Cheers.
0
marcus_careyAuthor Commented:
Dave

I got this work but it's a nightmare.  There has to be an easier way.  I did not understand the example posted by meverest.
0
marcus_careyAuthor Commented:
I will post another question for meverest if they can provide a better explanation.
0
meverestCommented:
>> I did not understand the example posted by meverest

What i mean is that the cgi interface simply uses environment variables to deliver data to the cgi executable.

You know what data the exe expects to find, so you can simply SET those variables in the application environment, then just run the executable - it will grab all the data from ENV and display the html output to stdout.

cheers.
 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.