Solved

CGI with Dos batch?

Posted on 2002-06-21
7
356 Views
Last Modified: 2013-12-25
Just for fun:
Is it possible to create a CGI using a dos batch file?
If so, how does one issue the double \n\n ?

I tried the echo with character (255), but that's a value not a plain linefeed.







Please don't lock this question.
I will choose an answer from the comments.
0
Comment
Question by:Triskelion
[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
  • 4
  • 2
7 Comments
 
LVL 15

Expert Comment

by:samri
ID: 7099980
Triskelion,

Basicall, any programming language/script/etc. could be used as CGI program if it can send-out the data as per CGI/HTTP protocol requires.

To be simple, the code should be able to at least send out

Content-Type: text/html\n\n  as the first line on the code.

I am having the same problem like you mentioned; How do we send out \n\n.  One possibility if to write a small exe, or com or any other form that can send out this special char file just to print out double blank line (\n\n).
and that is exactly the problem .

--- test.bat , place in /cgi-bin/
@echo off
echo Content-Type: text/html
call out.pl
call out.pl
rem echo <html>
rem echo <head>
rem echo <title>Title</title>
echo a

-- out.pl to be in the same dir as test.bat.  And you need perl around.
#!c:\perl\bin\perl
print "$ARGV[0]\n";

---
This is one quick solution that I can think off.  Well if you had Perl around, why need batch file anyway :)

0
 
LVL 15

Expert Comment

by:samri
ID: 7100038
OK, the \n\n, can be done with echo. (no space between echo and .)

so
---
@echo off
echo Content-Type: text/html
echo.
echo.
---

Should give a proper HTTP Header.

But the problem still on how to print out HTML TAG; ie <HEAD> etc.etc.  The DOS shell seems to complain about the redirection.
0
 
LVL 15

Accepted Solution

by:
samri earned 50 total points
ID: 7100057
Haha... I got it.

Make sure you had sl.txt, gt.txt, st.txt, where the files would contains a single >,<,/ or any html quoting (or whatever).

gt.txt contain >
st.txt contain <
sl.txt contain /
you can add more.

--- it's kinda of fun.

the batch file.
------------
@echo off
echo Content-Type: text/html
echo.
echo.
type st.txt
echo HTML
type gt.txt

type st.txt
echo HEAD
type gt.txt

type st.txt
echo TITLE
type gt.txt

echo This is my Title
type st.txt
type sl.txt
echo TITLE
type gt.txt

type st.txt
echo BODY
type gt.txt

echo Whatever your body is
type st.txt
type sl.txt
echo BODY
type gt.txt

type st.txt
type sl.txt
echo HTML
type gt.txt
0
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

 
LVL 6

Author Comment

by:Triskelion
ID: 7107117
Interesting
0
 
LVL 15

Expert Comment

by:samri
ID: 7107993
Out of curiosity,

Do you happens to have any requirement that requires DOS batch file to be CGI enabled?

Very interesting thought sometime.  Btw, did you ever wonder how would other languages behaves, COBOL for example ?
0
 
LVL 6

Author Comment

by:Triskelion
ID: 7108035
No.  I was just playing around.
As a matter of fact, I was experimenting with PASCAL and ASM when I thought about the DOS batch issue.

It should be possible to make a CGI with anything that can produce the correct output.
I did, however, run across a problem when experimenting with ASM.  Here is a link to the question:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=cgi&qid=20314840
0
 

Expert Comment

by:polebridge
ID: 8599405
you can use ^ (shift-6) to escape the < and > 
For example:
echo ^<html^>
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

615 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