cgi

Is it faster to access data from files or a database server?

If I have a static database consisting of folders and files, would access and manipulation be faster than SQL server type databases, considering this would be used in a CGI script? When working with files and folders, what are the tricks to better performance? ...

How can I detach a process from a CGI so I can store and read files from memory?

Is it possible that I would be able to spawn a detached daemon like process, from a CGI script that stores read text files in memory, then re-access the memory in the next cgi execution, reading the data using a pipe? Would most hosting ISP's, allow detached processes? Are memory pipes fast, and easy to code/work with on a unix/linux sy...

How can I debug a possible memory leak in a Perl CGI script?

I have a legacy Perl CGI page running on Apache that processes a large Excel spreadsheet worth of data, adding to the database as necessary. It gets processed in groups of data, and each group of data gets sent to the database. After each call to the database, my system's available memory decreases significantly to the point where there...

HTTP request dispatch from Web Server to a CGI/FastCGI process

To gain more understanding of how HTTP requests are handled in case of web apps, how does a web server like Apache, dispatch a request to one of its Virtual Hosts? What are the initial programs executed irrespective of the framework (Rails/PHP/Java)? I would appreciate if someone can list the steps taking example of Rails (as I know Rail...

Are there flaws in my web session handling process?

Okay so the way this works is the user authenticates via web form and generates a session ID as so: sub session_open { my $sid; my $user = shift; if ( open(SEMA, "> ../sema/sess") ) { flock SEMA, LOCK_EX; do { $sid = generate_session_id(); } while ( -d "$SDIR/$sid" )...

Why do I get "Premature end of script headers" from my CGI proxy?

Hello, I have CGI proxy that works on my localhost, but when I try to get it work on another server I get Premature end of script headers. I have included the source below. I also tried print header instead of the text/xml and it worked localhost but it failed on the server. use strict; #use warnings; use CGI qw(:standard); use CGI::Car...

What is the difference between pre($ENV{'QUERY_STRING}) and ($cgi->param()) ?

for a perl cgi script, what is the difference (technically) between these two? #!/usr/bin/perl use CGI; $cgi = new CGI; print $cgi->header(), $cgi->start_html(), $cgi->pre($cgi->param()), $cgi->end_html(); and #!/usr/bin/perl use CGI; $cgi = new CGI; print $cgi->header(), $cgi->start_html(), $cgi->pre($ENV{'QUERY_STRING'}), ...

How can I troubleshoot my Perl CGI script?

I have a Perl script that isn't working and I don't know how to start narrowing down the problem. What can I do? Note: I'm adding the question because I really want to add my very lengthy answer to Stackoverflow. I keep externally linking to it in other answers and it deserves to be here. Don't be shy about editing my answer if you ha...

Which FastCGI server mode should I choose under Apache?

I am new to FastCGI and looking to use this platform to speed up my existing vanilla CGI (perl) programs. However in reading the FastCGI/Apache FAQ, it appears I can setup my scripts (once converted to use separate initialization/request sections) in the Apache config as one of the following: 1) dynamic 2) static "inside the scope of ...

Help me fix my website - which used to rotate homepage images on underlying image map.

Title: Rotate Homepage Image (for website)- No longer works. I am a physicist/wildlife artist with a website (I created in 2002) to display & market my artwork. I have set it up with an underlying (homepage) image map - having links to: "tigers", "leopards", "birds", artist info, etc., with the overlying image changing (swapping out) ev...

Access a DB from two different server using CGI

Need to access a DB from two different servers [ 123.123.125.12 , 75.182.16.36 ] using CGI in a single file ...

Why do my images get clipped when served by this Perl CGI script?

When I try to print an image to STDOUT in a Perl CGI script, the image gets clipped when viewed in the browser. Here is the following code: if ($path =~ m/\.jpe?g$/i) { my $length = (stat($path))[7]; $| = 1; print "Content-type: image/jpg\r\n"; print "Content-length: $length\r\n\r\n"; open(IMAGE,"<$path"); binmode(IMAG...

Cgi not executing python

Hello everyone. I'm having a problem getting CGI to work for Python. I've added Options ExecCGI AddHandler cgi-script cgi py pl inside /etc/apache2/sites-available/default within and now Perl works, but Python gives out a 500 Internal Server Error.. EDIT: This if the current 'default' file <VirtualHost *:80> ServerAdmin web...

Why does my CGI script complain "Can't locate CGI/Session.pm in @INC"?

Hi All, I am having a html file which will accept and send the login and password. It is sent to the file login.cgi. ** html file ** <form method="POST" action="login.pl"> <table > <tr> <td>Username </td> <td bgcolor="lightgrey"><input type="text" name="usr" size="20"></td> </tr> <tr> <td>Password </td> <td bgcolo...

How can I send POST and GET data to a Perl CGI script via the command line?

I am trying to send a get or a post through a command-line argument. That is test the script in the command line before I test through a browser (the server has issues). I tried searching online, and I suppose I was probably using incorrect terminology because I got nothing. I know this is possible because I saw someone do it. I just don...

How to save server state of CGI application?

I have a cgi web program (in C) that prints out different error messages to a log file. If the program is run again and runs into he same error, I do not want the same error message to log again. I'm looking at different options and any advice is appreciated. Thanks. -Cookie: unable to set cookie after the html <head> section has been p...

Python import MySQLdb, Apache Internal Server Error

I'm having a similar problem to that described in ".cgi problem with web server", although I reviewed and tested the previously suggested solutions without success. I'm running the same program on Mac OS X 10.5.8, Apache 2.2.13, using Python 2.6.4. I can successfully run the code in the python shell and the terminal command-line, but I...

How can I parse and echo CGI query string parameters?

I would like to execute a command on the server by using the system request parameters in the URL. I am running the server. In the browser ->> //localhost:9009/?comd which is displaying the list of files in the directory as i placed in the code if (/comd/i ) { print $client `dir`; } How I can parse the request parameters...

Setting up Ruby CGI in Apache

I want to use Ruby in Apache through CGI. I have the following in my configuration file: DocumentRoot /home/ceriak/ruby <Directory /home/ceriak/ruby> Options +ExecCGI AddHandler cgi-script .rb </Directory> test.rb is a testfile placed under /home/ceriak/ruby/, #!/usr/bin/ruby included on the first line and given executable pe...

Set REMOTE_ADDR to X-Forwarded-For in apache

In a situation where Apache is sitting behind a reverse proxy (such as Squid), the cgi environment variable REMOTE_ADDR gets the address of the proxy rather than the client. However, the proxy will set a header called X-Forwarded-For to contain the original IP address of the client so that Apache can see it. The question is, how do we ...