• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

FCGI begginer's qs

Hi,

I am new to web programming. And i dont have much idea about FCGI, so please bear with me..
I created this simple FCGI program. When i run this script from browser, it gives me the output below:

Program not run as FastCGI
FastCGI Demo Page2 (perl)
This is connection number 1

What could be the error?
Is there some special way to run FCGI scripts so that this script keeps running and wait for more connections?

I dont know what to do and how to write a valid FCGI script. Any help would be great.
Thanks.

-------------------------------------------------------
Below is the code i am using:
  #!/usr/bin/perl -w
  use FCGI;

  $cnt = 0;
  $fcgi = FCGI::Request();

  while ($fcgi->Accept >= 0) {
    print "Content-type: text/html\r\n\r\n";
    if($fcgi->IsFastCGI()) {
          print "<h3>Program run as FastCGI</h3>\n";
    } else {
          print "<h3>Program not run as FastCGI</h3>\n";
    }
    print "<head>\n<title>FastCGI Demo Page</title>\n</head>\n";
    print  "<h3>FastCGI Demo Page</h3>\n";
    $cnt++;
    print "This is connection number $cnt\n";
  }
0
Arunima76
Asked:
Arunima76
  • 7
  • 5
1 Solution
 
ahoffmannCommented:
have you configured your server for FCGI with perl? for example mod_cgi in apache
0
 
Arunima76Author Commented:
Sorry for late response..

> have you configured your server for FCGI with perl? for example mod_cgi in apache
How can i check this myself? Or do i have to ask my server admin?
0
 
ahoffmannCommented:
>  Or do i have to ask my server admin?
i.g. yes
Depending on your type/vendor of FCGI, there're special perl modules available which you can check yourself, for example:
   use FCI;
or
  use CGI::Fast;

> How can i check this myself?
if you've a lazy admin or an insecure server:
  http://your.tld/server-info and http://your.tld/server-info  (if it is an apache)
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Arunima76Author Commented:
by FCI do you mean FCGI?

I think FCGI module is installed because my program compiles & executes without any error.
0
 
ahoffmannCommented:
yes FCGI
just the presence of a perl module does not prove that fast CGI is enabled in the server, ask the admin
0
 
Arunima76Author Commented:
Seems like fast CGI is disabled on the server.

Otherthan that, is there any error in my code?
As i asked before, how should one run FCGI scripts so that it keeps running and wait for more connections?
I am running it from browser. Is this ok?
0
 
ahoffmannCommented:
> I am running it from browser. Is this ok?
you never run somthing "from browser"
If the server has not enabled FCGI, then each request to a cgi starts a new process which inherits all informations needed from the web server.
If such a process should wait for other connections, you have to code it. But i.g. that's a bad solution.
0
 
Arunima76Author Commented:
I got your point.
I tried my script with server enabled for FCGI. Its working fine.

Now how do i stop it? I dont have permission to kill a process.

Thanks.
0
 
ahoffmannCommented:
> Now how do i stop it? I dont have permission to kill a process.
if you have not implemented a command for termination, then you can't stop it yourself.
0
 
Arunima76Author Commented:
I tried this. The process terminates but starts again after few minutes. Sometimes it starts immedately.

Thanks.

------------------------------------------------------
  use FCGI;
  $cnt = 0;
  $fcgi = FCGI::Request();

  while ($fcgi->Accept >= 0) {
    print "Content-type: text/html\r\n\r\n";

    if($fcgi->IsFastCGI()) {
          print "Program run as FastCGI<br>\n";
    }
    print "This is connection number ", ++$cnt;

    $fcgi->Finish();                                     <===
    $fcgi->Flush();                                      <===
    last          if $cnt>=3;                            <===
  }
  exit(0);                                                   <===
0
 
Arunima76Author Commented:
Any suggestions ??
0
 
Arunima76Author Commented:
Thanks for your help.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now