Solved

unstoppable cgi

Posted on 1998-06-21
9
294 Views
Last Modified: 2013-12-25
os: win95
server: netscape fasttrack 2.0

question: i m a beginner to cgi scripting, i've been reading tutorials n introductions during these few weeks on the net, n i've tried writing scripts by myself using batch files, pascal n c. they all works fine, but they just won't stop!

for eg, (a batch file):
  @echo off
  echo Content-type: text/html
  echo.
  echo.
  type a.txt
  exit
n in the a.txt file:
  <HTML><BODY>
  blahblahblah..
  </BODY></HTML>

i thought i could get a line of blahblahblah.. on my browser when i call this bat, but the result is that i can just get a blank screen with my browser telling me xxxbytes read, n the browser just keep waiting n waiting until i press ESC, which is the time i can finally c "blahblahblah..".

i have downloaded some free exe scripts on the net, n they all work very fine on my server. the only difference i notice is that when i tried to double click on these exe files, it pops up a dos window n when it's finished, it close the dos window. when i double click on the exe files i made (by pascal/c), they pops up a dos window, but couldn't close the dos window after finished. it also happens when i compile the free cgi source codes using pas/c. adding return(0) at the end of the program wouldn't help also.


what's wrong actually? is that i have to put something at the end of the source code? or is that i have to use some special compiler? (i m using borland pascal 7.0, turbo c 3.0) or is that something related to my server? (i've added exe n bat as a cgi type in the mime file) or is that win95's own problem?
0
Comment
Question by:rabili
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:rabili
ID: 1829904
Edited text of question
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829905
Your example closes fine on my pc... Perhaps you have a problem

It seems you need to flush the server cache...

At least make sure your program is outputting
Content-type: text/html\n\n      <<<<< Notice TWO newlines

I would also put a newline after the </HTML>

Michel
0
 

Author Comment

by:rabili
ID: 1829906
this is the c program i made:

#include <stdio.h>
int main()
{
       printf("Content-type: text/html\n\n");
       printf("<HTML><BODY>\n");
       printf("<HR><BR>\n");
       printf("blahblah..");
       printf("<HR><BR>\n");
       printf("blahblah..");
       printf("</HTML></BODY>\n");
       return(0);
}

anything wrong?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829907
Looks fine to me...

Not knowing C I would still expect a stdout somewhere and I would perhaps do a fflush(stdout) as well?

Michel
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Expert Comment

by:rcashon
ID: 1829908
rabili, I have been having a similiar problem with my system. Are you running a personal web server on your box? Also, when the CGI executes does it function correctly, but continue to run as though it was searching for exe to run till it times out?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829909
Could it be a 16 bit problem?

I gor this at DejaNews:

Seems to be a 16-bit vs. 32-bit problem.  I recompiled the same code
under VC++ 4.0 as a 32-bit console app and it worked just fine.  MS
wants it to be a 32-bit world...
0
 

Author Comment

by:rabili
ID: 1829910
i've tried this on both pws n netscape fasttrack, n the results r exactly the same.

so if it's really a 16 bit problem, do i need a 32bit c-compiler for making cgi?
0
 
LVL 1

Expert Comment

by:rcashon
ID: 1829911
rabili, It is definatly a 32 bit problem. Mplungjan gave me the comment in the javascript section also. I recompiled using Visual C++ 4.0 and my cgi terminated after it executed correctly. So he was correct with it needing to be compiled as a 32 bit application rather than a 16 bit app. And yes , you will need a 32 bit compiler if you are going to be writing your cgi's in C. I'm new to the CGI in web development and this one problem has been a pain in my rear for a 2 months. Now I can get back to some coding. Mplungjan will probally post that as an answer as I responded over in the Javascript section. Good luck!
Randall
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1829912
Two birds in one stone

From Dejanews:

Seems to be a 16-bit vs. 32-bit problem.  Recompile the same code
(under VC++ 4.0) as a 32-bit console app and it should work just fine.  MS
wants it to be a 32-bit world...

Michel
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
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.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 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

16 Experts available now in Live!

Get 1:1 Help Now