Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • Last Modified:

executing .bat files as CGI on WIN NT 4.0

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
wrobel
Asked:
wrobel
  • 5
  • 3
1 Solution
 
fasterCommented:
bat file is very limited in function, it can not be compared with unix shell script.  Why not use Perl or normal exe?
0
 
wrobelAuthor Commented:
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
 
wrobelAuthor Commented:
Dear Faster,
    I may have to persevere with .bat files.
So what is this 501 error I'm getting?
    Yours
    Allan
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wrobelAuthor Commented:
Do You have any example .bat's?

0
 
fasterCommented:
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
 
wrobelAuthor Commented:
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
 
fasterCommented:
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
 
wrobelAuthor Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now