Setting up webserver for perl / cgi scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tovenkatesh82
    New Member
    • Mar 2007
    • 30

    Setting up webserver for perl / cgi scripts

    how to get the output of .cgi file in browser?

    this is the code i am using:

    Code:
     #!/usr/bin/perl ; 
    use CGI;
    my $cgi = CGI->new();
    print $cgi->a(
    {-href => "http://www.google.com/"},
    "ask me."
    );
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Hi toven,

    You need a webserver. Here's a good one:

    http://httpd.apache.or g/


    - Miller

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      You also need to print a header before printing any other output to the browser:

      Code:
      #!/usr/bin/perl
      use CGI;
      my $cgi = CGI->new;
      [B]print $cgi->header();[/B]
      print $cgi->a(
      {-href => "http://www.google.com/"},
      "ask me."
      );
      there should be no ';' at the end of the shebang line:

      Code:
      #!/usr/bin/perl ;
      see above corrected code

      Comment

      • tovenkatesh82
        New Member
        • Mar 2007
        • 30

        #4
        I have installed Apache and made the suggested change in the code still i am not getting the output on browser.


        Originally posted by KevinADC
        You also need to print a header before printing any other output to the browser:

        Code:
        #!/usr/bin/perl
        use CGI;
        my $cgi = CGI->new;
        [B]print $cgi->header();[/B]
        print $cgi->a(
        {-href => "http://www.google.com/"},
        "ask me."
        );
        there should be no ';' at the end of the shebang line:

        Code:
        #!/usr/bin/perl ;
        see above corrected code

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          if you're on Windows the shebang line probably needs to be:

          #!c:\perl\bin\p erl.exe

          or this might also work:

          #!perl

          Comment

          • tovenkatesh82
            New Member
            • Mar 2007
            • 30

            #6
            yes i am on windows and applied what you suggested for shebang line but nothing works.

            Originally posted by KevinADC
            if you're on Windows the shebang line probably needs to be:

            #!c:\perl\bin\p erl.exe

            or this might also work:

            #!perl

            Comment

            • KevinADC
              Recognized Expert Specialist
              • Jan 2007
              • 4092

              #7
              goggle around for a tutorial on how to setup the version of apache you have to run cgi/perl scripts, I have a feeling that is where the problem is. You have to edit a configuration file to get cgi stuff working.

              Comment

              • tovenkatesh82
                New Member
                • Mar 2007
                • 30

                #8
                thanks i was able to resolve the issue.

                Originally posted by KevinADC
                goggle around for a tutorial on how to setup the version of apache you have to run cgi/perl scripts, I have a feeling that is where the problem is. You have to edit a configuration file to get cgi stuff working.

                Comment

                • miller
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1086

                  #9
                  Originally posted by tovenkatesh82
                  thanks i was able to resolve the issue.
                  Awesome. Glad you are able to get it resolved.

                  - Miller

                  Comment

                  Working...