ScriptBasic
May 22, 2012, 02:31:57 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Registration Disabled Send an e-mail to support @ scriptbasic.org to request a membership to this forum. (include desired forum name)
 
   Home   Wiki Help Search Login Register  
Pages: [1]
  Print  
Author Topic: cgi module  (Read 529 times)
RONB
Newbie
*
Posts: 35


« on: October 20, 2011, 12:18:02 PM »

I need to set a cgi environment variable for using htmldoc. I see where you can read the environment using
Code:
i=0
do
  e$ = environ(i)
  if IsDefined(e$) then
    print e$
    print
  endif
  i = i + 1
loop while IsDefined(e$)
, but can find no help on how to set or create a variable.
HTMLDOC_NOCGI = 1
-------
here is the example they gave for perl
Code:
sub topdf {
# Get the filename argument...
my $filename = shift;

# Make stdout unbuffered...
select(STDOUT); $| = 1;

# Tell HTMLDOC not to run in CGI mode...
        $ENV{HTMLDOC_NOCGI} = 1;

# Write the content type to the client...
print "Content-Type: application/pdf\n\n";

# Run HTMLDOC to provide the PDF file to the user...
system "htmldoc -t pdf --quiet --webpage $filename";
    }
 
Thanks, Ron
Logged
support
Administrator
*****
Posts: 409


« Reply #1 on: October 20, 2011, 02:38:24 PM »

Ron,

I normally set environment variables with the SYSTEM or EXECUTE SB command. Are you starting your CGI scripts using the scriba -c command to tell SB that the script is CGI based?

Quote
CGI programs gain a great wealth of information from environment variables. This data is available to the ScriptBasic program via module functions. The CGI program is encouraged to use these functions instead of the function environ(). The reason to use these functions is that later versions of the CGI module may support ISAPI, NSAPI, FastCGI and other web server interface modes. Calling the function environ() to get the value of these variables will not work in that case, while calling the functions provided by the CGI module still works.

John

Update

Quote
.htaccess files are reread upon every hit within that directory. In fact, the web server will look for these .htaccess files on every access to the web server.

If using Apache, you may be able to set your environment variable by creating a .htaccess file in the directory your script is running and add the following.

SetEnv HTMLDOC_NOCGI "1"

« Last Edit: October 20, 2011, 04:39:05 PM by support » Logged
RONB
Newbie
*
Posts: 35


« Reply #2 on: October 20, 2011, 08:43:51 PM »

Thanks for the info John. Using the .htaccess is a good idea. After installing and uinstalling a bunch of apps my scriba install is gone. Will reinstall the scriba linux version in a few minutes and try again.
Logged
support
Administrator
*****
Posts: 409


« Reply #3 on: October 20, 2011, 09:39:23 PM »

After my previous post I gave the .htaccess method a try and it worked fine. That should be a quick way to solve your issue.

In general, how are your adventures going with ScriptBasic?

Logged
support
Administrator
*****
Posts: 409


« Reply #4 on: October 21, 2011, 06:45:58 AM »

Another way to set CGI environment variables is to specify them as either GET or as POST parameters in the http request.
« Last Edit: October 21, 2011, 06:53:36 AM by support » Logged
RONB
Newbie
*
Posts: 35


« Reply #5 on: October 21, 2011, 01:33:34 PM »

Code:
[quote author=support link=topic=232.msg703#msg703 date=1319204758]
Another way to set CGI environment variables is to specify them as either GET or as POST parameters in the http request.
[/quote]
Do you mean like this?
[code]
form-
<input type="hidden" name="HTMLDOC_NOCGI" value="true">
sb prg-
#!/usr/bin/scriba -c
INCLUDE cgi.bas
OPTION cgi$Method cgi::Post or cgi::Get
cgi::PostParam("HTMLDOC_NOCGI")

or should it be-
HTMLDOC_NOCGI=cgi::PostParam("HTMLDOC_NOCGI")

-------
The sbhttpd server is solid and have made a number of programs for it. Most are xml data parses.
I was going to start compiling more SB modules and ran into the file location problem. I changed these by hand one time on the few I compiled.
Code:
/home/riveraa/tmp/scriptbasic/
C:\\ScriptBasic\\
I am going to globally change to
/usr/src/scriptbasic/
-----------
I am still trying to get a working copy of the GD graphics library for linux. The open source project seems to be in disarray. The japi (java) SB module does more really, so have changed servers.
Was using unbutu server LAMP install. Just changed to ubuntu server tomcat 6 for the java server, still setting up. The biggest problem is testing the home server, as it has to be accessed locally to load it. Often remote users off the web run into different problems that I can not see. If you know a way around this I would love to know it. The biggest problem using scriptbasic I think is the lack of examples in the documentation. Many times a lot of time is spent trying to figure out how a command works, what the syntax is. Where examples are shown sometimes they are the most complex and involved imaginable. I simple example would serve as a better starting point for new users maybe.
Later, Ron










[/code]
« Last Edit: October 21, 2011, 01:45:17 PM by RONB » Logged
support
Administrator
*****
Posts: 409


« Reply #6 on: October 21, 2011, 06:36:12 PM »

Ron,

I'm trying to understand what you're after. I assumed that you're sending  a request to a non-SB page/script that is looking for a special environmental variable to be set. Can you be more specific what you're trying to accomplish?

John

P.S.

Thanks for your feedback about SB.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!