Loading ...
Sorry, an error occurred while loading the content.

Linux Perl Script Problem

Expand Messages
  • Eric Boyajian
    This is possibly more of a Red Hat Linux problem than a Perl problem, but perhaps someone here can help me. I m trying to migrate a simple website that uses
    Message 1 of 9 , Feb 6, 2007
    • 0 Attachment
      This is possibly more of a Red Hat Linux problem than a Perl problem,
      but perhaps someone here can help me. I'm trying to migrate a simple
      website that uses HTML forms and Perl scripts to a new computer that
      was recently set up with Red Hat Linux Enterprise ES 4.

      I have a perl script called test.cgi as follows:

      ====================================
      #!/usr/bin/perl -W
      print("Hello World\n");
      ====================================

      The script has mode file permission 777. The folder in which it
      resides (and all parent folders) have permission 755.

      If I call the Perl interpreter directly and pass the script as an
      argument, it works:

      [root@testlinux cgi-bin] # /usr/bin/perl test.cgi
      Hello World
      [root@testlinux cgi-bin] #


      If I run it as a script as follows, it does not work:

      [root@testlinux cgi-bin] # ./test.cgi
      [root@testlinux cgi-bin] #


      The disk is mounted as:
      /dev/sda3 on / type ext3 (rw)


      Does anyone have suggestions as to what to look for to resolve this?

      Thanks,

      Eric
    • Frank Kleinburg (el Oso de Tejas)
      Since you are not getting an error to the screen, I d suspect it s running, just sending the output to an unexpected location.. Try changing the print to:
      Message 2 of 9 , Feb 6, 2007
      • 0 Attachment
        Since you are not getting an error to the screen, I'd suspect it's
        running, just sending the output to an unexpected location.. Try
        changing the print to:

        `echo "hello world" > test.txt`;

        and then see of the file test.txt is created.. You might get a
        permissions error when it tries to create the file, but at least
        you know the program is running, and can look into why the display
        isn't being set properly..

        Also running:

        `env > environment.txt`;

        is very helpful in determining just what environment is being passed
        to the program.. flk k
      • Scott Ford
        Eric: I have Perl 5.8.8 on Fedora Core 5 - Kernel 2.6.18-1.2257.fc5. My perl scripts are in the following folder /programs/scripts/perl ...I can execute it
        Message 3 of 9 , Feb 6, 2007
        • 0 Attachment
          Eric:

          I have Perl 5.8.8 on Fedora Core 5 - Kernel 2.6.18-1.2257.fc5. My perl scripts are in the
          following folder /programs/scripts/perl ...I can execute it directly from that directory or
          with the following cmd:

          perl /root/programs/scripts/perl perlping.pl

          For what it's worth I would check my PATH , by 'echo $PATH' make sure you have the
          correct directories in the PATH. Hope this helps...

          Regards,
          Scott



          Eric Boyajian <ericboyajian@...> wrote:
          This is possibly more of a Red Hat Linux problem than a Perl problem,
          but perhaps someone here can help me. I'm trying to migrate a simple
          website that uses HTML forms and Perl scripts to a new computer that
          was recently set up with Red Hat Linux Enterprise ES 4.

          I have a perl script called test.cgi as follows:

          ====================================
          #!/usr/bin/perl -W
          print("Hello World\n");
          ====================================

          The script has mode file permission 777. The folder in which it
          resides (and all parent folders) have permission 755.

          If I call the Perl interpreter directly and pass the script as an
          argument, it works:

          [root@testlinux cgi-bin] # /usr/bin/perl test.cgi
          Hello World
          [root@testlinux cgi-bin] #

          If I run it as a script as follows, it does not work:

          [root@testlinux cgi-bin] # ./test.cgi
          [root@testlinux cgi-bin] #

          The disk is mounted as:
          /dev/sda3 on / type ext3 (rw)

          Does anyone have suggestions as to what to look for to resolve this?

          Thanks,

          Eric






          ---------------------------------
          Get your own web address.
          Have a HUGE year through Yahoo! Small Business.

          [Non-text portions of this message have been removed]
        • Eric Boyajian
          Thank you for your suggestions. I tried both `echo hello world test.txt`; and `env environment.txt`; but no files were created. I believe that Linux is
          Message 4 of 9 , Feb 7, 2007
          • 0 Attachment
            Thank you for your suggestions. I tried both

            `echo "hello world" > test.txt`;

            and

            `env > environment.txt`;

            but no files were created.

            I believe that Linux is truly refusing to start a Perl interpreter.

            I forgot to mention that this script only fails in the cgi-bin
            directory but seems to work in all other directories. Perhaps there
            is some interaction between the Apache webserver and the Linux
            shell. (The httpd.conf file specifies that the Apache webserver
            should run scripts in the cgi-bin directory. "Option ExecCGI")

            I have not yet tested whether the webserver will properly launch CGI
            scripts. I first wanted to make sure that Perl works -- which it
            does except for in the cgi-bin directory! Weird stuff. Perhaps I
            can work around this by simply keeping my scripts outside the cgi-bin
            directory.

            Eric
          • Eric Boyajian
            Scott, Thanks you for your advice. My path PATH looks good -- it includes /usr/bin so I can indeed run Perl by simply typing perl in any working directory.
            Message 5 of 9 , Feb 7, 2007
            • 0 Attachment
              Scott,

              Thanks you for your advice. My path PATH looks good -- it
              includes /usr/bin so I can indeed run Perl by simply typing "perl" in
              any working directory. I just cannot get Linux to run the perl file as
              a script when it is in the cgi-bin directoy. It seems to run properly
              as a script when placed in any other directory. Weird!

              There must be some Linux or Apache or Perl configuration setting
              somewhere that I don't about.

              At this point, I think I'll simply put my perl scripts outside the cgi-
              bin directory and move on.

              Eric
            • Scott Ford
              Eric: I would be looking at the Apache configuration files. I had a problem running PHP and Postgresql and it had to do with the Apache configs. I haven t used
              Message 6 of 9 , Feb 7, 2007
              • 0 Attachment
                Eric:

                I would be looking at the Apache configuration files. I had a problem running PHP and Postgresql and it had to do with the Apache configs. I haven't used Perl cgi yet on Apache. I will look for you also on my system and see if I can find it for you. I am currently looking for for work so I have time on my hands..
                Take care. let you know as soon as I can..

                Scott

                Eric Boyajian <ericboyajian@...> wrote: Scott,

                Thanks you for your advice. My path PATH looks good -- it
                includes /usr/bin so I can indeed run Perl by simply typing "perl" in
                any working directory. I just cannot get Linux to run the perl file as
                a script when it is in the cgi-bin directoy. It seems to run properly
                as a script when placed in any other directory. Weird!

                There must be some Linux or Apache or Perl configuration setting
                somewhere that I don't about.

                At this point, I think I'll simply put my perl scripts outside the cgi-
                bin directory and move on.

                Eric






                ---------------------------------
                Have a burning question? Go to Yahoo! Answers and get answers from real people who know.

                [Non-text portions of this message have been removed]
              • Scott Ford
                Eric: I found a website that might help you out. http://www.thesitewizard.com/archive/addcgitoapache.shtml I scanned through this site and it looks like it
                Message 7 of 9 , Feb 7, 2007
                • 0 Attachment
                  Eric:

                  I found a website that might help you out.

                  http://www.thesitewizard.com/archive/addcgitoapache.shtml

                  I scanned through this site and it looks like it gives the user a step by step
                  howto for adding cgi/perl support to Apache. I would suggest this is a good place to start. Let me know if you need help. I have Apache running on Fedora Core 5....in a 6 pc network here at home including wireless pcs..So i can help let me know.

                  Regards,
                  Scott

                  Eric Boyajian <ericboyajian@...> wrote: Scott,

                  Thanks you for your advice. My path PATH looks good -- it
                  includes /usr/bin so I can indeed run Perl by simply typing "perl" in
                  any working directory. I just cannot get Linux to run the perl file as
                  a script when it is in the cgi-bin directoy. It seems to run properly
                  as a script when placed in any other directory. Weird!

                  There must be some Linux or Apache or Perl configuration setting
                  somewhere that I don't about.

                  At this point, I think I'll simply put my perl scripts outside the cgi-
                  bin directory and move on.

                  Eric






                  ---------------------------------
                  Be a PS3 game guru.
                  Get your game face on with the latest PS3 news and previews at Yahoo! Games.

                  [Non-text portions of this message have been removed]
                • Eric Boyajian
                  Scott, I ve been able to get my scripts running in various non-cgi-bin directories, and my website is up and running. I m being pulled off to do other things
                  Message 8 of 9 , Feb 8, 2007
                  • 0 Attachment
                    Scott,

                    I've been able to get my scripts running in various non-cgi-bin
                    directories, and my website is up and running. I'm being pulled off
                    to do other things now, but I will try to figure out the basic
                    problem at some point.

                    Thank you very much for your help.

                    Best regards,

                    Eric


                    --- In perl-beginner@yahoogroups.com, Scott Ford <scott_j_ford@...>
                    wrote:
                    >
                    > Eric:
                    >
                    > I found a website that might help you out.
                    >
                    > http://www.thesitewizard.com/archive/addcgitoapache.shtml
                    >
                    > I scanned through this site and it looks like it gives the user a
                    step by step
                    > howto for adding cgi/perl support to Apache. I would suggest this
                    is a good place to start. Let me know if you need help. I have Apache
                    running on Fedora Core 5....in a 6 pc network here at home including
                    wireless pcs..So i can help let me know.
                    >
                    > Regards,
                    > Scott
                  • Scott Ford
                    Eric: Glad I could help you out a little. Still smells like an Apache configuration issue. Like something missing in your configuration file. I haven t had the
                    Message 9 of 9 , Feb 8, 2007
                    • 0 Attachment
                      Eric:

                      Glad I could help you out a little. Still smells like an Apache configuration issue. Like
                      something missing in your configuration file. I haven't had the time to try mine. I will do like
                      I promised to hrlp you out..

                      Regards,
                      Scott

                      Eric Boyajian <ericboyajian@...> wrote:
                      Scott,

                      I've been able to get my scripts running in various non-cgi-bin
                      directories, and my website is up and running. I'm being pulled off
                      to do other things now, but I will try to figure out the basic
                      problem at some point.

                      Thank you very much for your help.

                      Best regards,

                      Eric

                      --- In perl-beginner@yahoogroups.com, Scott Ford <scott_j_ford@...>
                      wrote:
                      >
                      > Eric:
                      >
                      > I found a website that might help you out.
                      >
                      > http://www.thesitewizard.com/archive/addcgitoapache.shtml
                      >
                      > I scanned through this site and it looks like it gives the user a
                      step by step
                      > howto for adding cgi/perl support to Apache. I would suggest this
                      is a good place to start. Let me know if you need help. I have Apache
                      running on Fedora Core 5....in a 6 pc network here at home including
                      wireless pcs..So i can help let me know.
                      >
                      > Regards,
                      > Scott






                      ---------------------------------
                      Don't get soaked. Take a quick peak at the forecast
                      with theYahoo! Search weather shortcut.

                      [Non-text portions of this message have been removed]
                    Your message has been successfully submitted and would be delivered to recipients shortly.