Solved

executing .bat files as CGI on WIN NT 4.0

Posted on 1997-10-02
8
524 Views
Last Modified: 2013-12-25
Dear Sir/Madam,

    I am trying to execute a bat file as a CGI script
on a WIN NT 4.0 web server. I have managed to associate
c:\%SystemRoot%\System32\cmd.exe with .bat files and
.cgi files using the registry.
   I have HTML files that I access over the Net and FORM
statements within that ACTION these .bat files.

   The result of attempting to execute this batch file
is HTTP: error 501 which in my documentation just says
"cannot assign a varable".

   I dont know how to write .bat command files that are
compatable with the web. I have written equilivent shell
scripts for UNIX ok, so I'm fairly up to speed.

   Searching the net I just find example CGI for UNIX
I cannot find example CGI .bat files for WIN NT.

   By the way my latest attempt at a .bat file looks like:

echo "Context-type: text/html"
echo ""

echo "Some Text"

Also How do I pass search queries into these .bat CGI
files? I think they are environment varables but an
example would go down a treat.

      Could any one help.

      Yours Faithfully
      Allan Wrobel

      cairs-support@cairs.co.uk
0
Comment
Question by:wrobel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1830712
bat file is very limited in function, it can not be compared with unix shell script.  Why not use Perl or normal exe?
0
 

Author Comment

by:wrobel
ID: 1830713
Dear Faster,
    Thanks for replying.
I will try to use .exe files, but what is the interfase to
.exe files. Do queries come over in the argc/argv
manner? Do I just write to standard output?
Do I have to write a slightly different 'C' executable
for all the different jobs in our web space?

    Yours
    Allan Wrobel
    cairs-support@cairs.co.uk
0
 

Author Comment

by:wrobel
ID: 1830714
Dear Faster,
    I may have to persevere with .bat files.
So what is this 501 error I'm getting?
    Yours
    Allan
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:wrobel
ID: 1830715
Do You have any example .bat's?

0
 
LVL 7

Expert Comment

by:faster
ID: 1830716
Your bat file seems to be OK, I am afraid that the error is from the configuration, I mean, probably the way to invoke bat file is not correct.

To write CGI in c/c++, you need to either read the stdin (for POST) or get the request from the env variables.  I can email you a sample program if you wish.
0
 

Author Comment

by:wrobel
ID: 1830717
Dear Faster,
    Thanks for replying.
Yes I would be very thankful for an example 'c'
program.
    I still don't understand the point about
associating a file extension with a particular handler
in NT. If an ACTION to a HTML FORM statment refers to
an .exe file that I write its that exe that I want
executed. But NT seems to require that I associate
file extensions with some handler that then executes
to process the argument to the ACTION in the FORM.
    Do I have to write a .exe hander that gets the
target .exe as a argument and then proceeds to execute
the target exe?
      Yours Rather confused
      Allan
      cairs-support@cairs.co.uk

0
 
LVL 7

Accepted Solution

by:
faster earned 220 total points
ID: 1830718
For an exe file, you need not have any kind of association.  What webser are you using?  Normally you only need to config a cgi directory and put your exe file there.  If you are using Netscape Enterprise server, the directory should be a normal CGI directory, not shell-cgi.

I will send you some parts of my cgi source code.
0
 

Author Comment

by:wrobel
ID: 1830719
Thanks for the example source.
I am running on a DELL machine Microsoft Win NT 4.0.
I have execute permission on the directory that
holds the .exe file. The FORM statment references
the correct file in the correct directory and I
still get error 501.
I have found a better description of the error
it's "The server does not support the functionality
required to fulfill the request."
Until I can solve this 501 error I am totally stuck.
     Yours
     Allan

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question