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

x
?
Solved

CGI with Dos batch?

Posted on 2002-06-21
7
Medium Priority
?
370 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
  • 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 200 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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.
Suggested Courses

916 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