Solved

executing .bat files as CGI on WIN NT 4.0

Posted on 1997-10-02
8
514 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
  • 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
 

Author Comment

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

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now