Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CGI with Dos batch?

Posted on 2002-06-21
7
Medium Priority
?
361 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

718 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