×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CGI executables in QBasic

CGI executables in QBasic

CGI executables in QBasic

(OP)
I've used QBasic for years, but still know just enough to be dangerous.  Can I get any suggestions for writing CGI in QBasic?

I tried this to test:

PRINT "Content-Type: text/html"
PRINT
PRINT "<HEAD><TITLE>This is a test.</TITLE></HEAD>"
PRINT "<BODY>"
PRINT "</BODY>"

I'd assumed that when called it would spit out a simple web page.  Instead, it glitches out, and won't run on the server, so I obviously have the wrong idea of how CGIs work.  Could someone give me a hand here?

By-the-way, I've tried getting into that www.qb45.com site, and it doesn't work.

-Javin

RE: CGI executables in QBasic

A CGI script is usually written in Perl, not Qbasic.  A browser doesn't understand *.BAS files.  If you want, you can find a Perl/CGI tutorial at www.webmonkey.com. ; It's a very powerful language.

And on the qb45.com thing, click on Qbasic/QuickBasic at the top.

RE: CGI executables in QBasic

CGI scripts are often used to present form-based pages, such as order forms or surveys not just simple text contents.




Secrete of life: If Husband = Happy then Wife = Unhappy. If Wife = Happy then Husband = Unhappy. If Parents = Happy then Kids = Unhappy. If Kids = Happy then Parents = Unhappy.

RE: CGI executables in QBasic

the code should work fine (remove the second PRINT statement, or use 'PRINT "<br>"')

You gotta compile to .EXE in order to make it work or maybe it won't work ? dunno, never try it before.

Use QuickBASIC or some other BASIC compiler to compile it.

RE: CGI executables in QBasic

(OP)
See, that's just it.  I have another .EXE file that does the EXACT same thing, gives you the exact same output when run, and it works.  So I wrote the QBasic program to mimic it, and compiled it into an .EXE, yet the server kicks an error when it's run.  

Is there maybe a different method that the information is actually being put out?  I'm going to be dealing with sensitive information, so I don't want to use a perl or VB script.  I need to have something that's going to be fairly safe.  Any scripts can be downloaded from the server, picked apart, and then they'll know the structure of the data on your server.

-Javin


RE: CGI executables in QBasic

I think it's probally need to be a specific type of exe. for example if I am correct in Qbasic you are mimicing to the console, where to a CGI you arnt directly communicating with a USer, more rather I belive you grab the input from the user then process it, but QBasic may be expecting a Dos Console. Not a Server. Some Languages just might not be adapt to be used in CGI.

Karl
kb244@kb244.com

Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)
http://www.brainbench.com/transcript.jsp?pid=629151

RE: CGI executables in QBasic

(OP)
Yeah, that's precisely what I'm afraid of.  I know it can be done, because I've SEEN people make CGI EXEs in QBasic, but I've never seen the code.  I'm afraid it's going to turn out to be some massively complex method of outputting the data by writing it out to a specific port or something.

-Javin

RE: CGI executables in QBasic

that or they had some special library made for QB45, to allow you to create the exe more easily, for example, until someone made that Graphical lib in ASM(Assembly) Qbasic graphics always been extremely slow.

Karl
kb244@kb244.com

Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)
http://www.brainbench.com/transcript.jsp?pid=629151

RE: CGI executables in QBasic

kb244 is right. QB writes to the CON device during a print routine, that's why it can't form flat binaries. CGI's in perl and C always write to STDOUT, which the web server can read. QB can probably do it, but it'll probably be easier to learn perl. You'll find that perl's structure is very close to BASIC, since they are both interpreted.

RE: CGI executables in QBasic

I was reading this thread and then sat down and pondered
about how to do cgi in qbasic and this link is the place
that tells you how to do it: http://docs.rinet.ru/UCGI/ch16.htm

RE: CGI executables in QBasic

Excellent link, eliuker! I know a few guys who have been banging their heads trying to find a way to do this. I'll pass it on.



A plain black box
"I sure hope I'm retired when it comes time to fix all the the Year-2000 problems in our systems!"
Edward Yourdon, Time Bomb 2000

RE: CGI executables in QBasic

(OP)
Eliuker-

You are a GOD.  That's exactly what I was looking for!  Thanks a bunch!

-Javin

Javin
Javin@Javin-Inc.com
Javin Inc.

Why don't sheep shrink when it rains?

RE: CGI executables in QBasic

(OP)
Okay, new problem.  I thorougly read through (even printed out) the link you gave me.  Unfortunately, it's talking specifically about DOS CGI.  DOS CGI isn't supported by my host, (nor is Perl, for some bizarre reason) so that's still a no-go.  Here's what I'm trying to do:

DEFINT A-Z

InStr$ = ENVIRON$("QUERY_STRING")

PRINT "Content-Type: text/html"
PRINT ""
PRINT "<HEAD><TITLE>This is a test."
PRINT "</TITLE></HEAD>"
PRINT "<BODY>"
PRINT "This is a test."
PRINT "Your input was as follows:"
PRINT InStr$
PRINT "</BODY>"

Still, even when given the proper permissions, it doesn't work.

-Javin



Javin
Javin@Javin-Inc.com
Javin Inc.

Why don't sheep shrink when it rains?

RE: CGI executables in QBasic

hmmmm as i say if your server dont got it make your own!
http://www.analogx.com has a server that will run on win95/98
did I also mention its VERY easy to use.

Have a nice day.

RE: CGI executables in QBasic

Ahh Javin I see why your program still dosent work.
although your program can get info from the server the server cant getinfo you send to it because you must send the print statements to the output_file. try this code (I havent yet).

<-------Start Copying here------->
 DEFINT A-Z

InStr$ = ENVIRON$("QUERY_STRING")
outfile$ = ENVIRON$("OUTPUT_FILE")

open outfile$ for output as #1
PRINT #1,"Content-Type: text/html"
PRINT #1,""
PRINT #1,"<HEAD><TITLE>This is a test."
PRINT #1,"</TITLE></HEAD>"
PRINT #1,"<BODY>"
PRINT #1,"This is a test."
PRINT #1,"Your input was as follows:"
PRINT #1,InStr$
PRINT #1,"</BODY>"
close #1
<-------End code------->

You were just printing but as the docs say you have to print to the output_file other wise its pretty pointless huh?
 

RE: CGI executables in QBasic

Javin,
   I'm just getting started in this cgi-bin thing and have alot of QuickBasic 4.5 background. This thread set was interesting and I'm wondering if you now have it down pat.
   Can a compiled QB .exe file be used successfully as CGI? If so, what are the basic "need-to-knows"?
thanks

RE: CGI executables in QBasic

1) did you follow a link?
Get thing about "DOS-CGI" part (server must support it)
2) output in binary form, so you can output generated JPG/GIF. If QBAsic can't do that - you'll end up with text output only
3) last thing. This is not exact quote; I cannot recall the author just now, but it can make you wonder.

"I played with CGI in VB for a month... then I get into Perl and easily recreated in 3 days all I got in VB in a month".

RE: CGI executables in QBasic

Yes, you need a server that supports "DOS CGI" which is a sort of a kludge like the old "Win CGI" that was used to support VB 3 for writing CGIs.

I've written lots of CGIs in VB 6.  These work fine with more generic servers like IIS or SimpleServer:WWW (AnalogX).  There are some hoops to jump through there too, but they aren't as insurmountable as writing a true QB CGI seems to be.  To expedite this I wrote a VB 6 program that takes very ASP-like syntax and generates and compiles a VB 6 CGI EXE.

That doesn't help here though.  Sorry Javin.

RE: CGI executables in QBasic

I found the problem and developed a hack around it (actually just an implementation of Microsoft's fix for the trouble).

I posted it over at QBasic/QuickBasic News in the forums (see Programming Help: Projects there).  I figured there were more QB developers on that site who might steal some of the ideas and benefit from them.

The actual problem: Windows has a problem with StdIO redirection to a 16-bit console application, described as a "hung pipe."

The (or one) fix: a 32-bit console application "stub" that fires up the 16-bit QB EXE in the same console after redirecting the new process' StdIO streams to its own.  There are stubs for this sort of thing around written in C and Delphi.  I did one in VB6.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close