Solved

executing .bat files as CGI on WIN NT 4.0

Posted on 1997-10-02
8
509 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

11 Experts available now in Live!

Get 1:1 Help Now