Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    4

    Default How to enable Perl-CGI in a Preferred Web Hosting account

    I signed up for the Preferred Web Hosting package, and one of the advertised features is Perl-CGI. However, my own Perl scripts always yield the dreaded [an error occurred while processing this directive] when I include them in my .shtml page. They all produce valid output when run from the shell.

    Even more puzzling to me is the fact that the cPanel-generated CGI programs work just fine, and produce the expected output both from the shell and my .shtml. I can place my own program side-by-side with the one cPanel generates in both the cgi-bin and scgi-bin directories and my programs will fail every time.

    What do I need to do to allow my own custom CGI programs to run?

  2. #2
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,716

    Default

    What permissions do you have your programs set to? They need to be executable. 755 Other common issues would be an incorrect path to perl or MS style new lines in your code.

    The first is pretty easy, make sure your first line is #!/usr/bin/perl

    The second is really pretty easy also. Make sure you don't use something like Word to create or edit your scripts. Use a plain text editor. There are two of them in my signature that are free to download.

    There are other things that can be the problem but I bet it is one of those.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    4

    Default

    Quote Originally Posted by wildjokerdesign View Post
    What permissions do you have your programs set to? They need to be executable. 755 Other common issues would be an incorrect path to perl or MS style new lines in your code.

    The first is pretty easy, make sure your first line is #!/usr/bin/perl

    The second is really pretty easy also. Make sure you don't use something like Word to create or edit your scripts. Use a plain text editor. There are two of them in my signature that are free to download.

    There are other things that can be the problem but I bet it is one of those.
    Thanks for the tips, wildjokerdesign, but it turns out they weren't the problem.
    The perms were already 755, and my shebang line is correct. I wrote the script in the shell with Vim.

    I finally discovered, by way of RTFM, that I needed to create public_html/cgi-bin/.htaccess with the following contents:

    Options ExecCGI Includes
    SetHandler cgi-script


    I had assumed that such a configuration would have already existed in my cgi-bin/ directory. But we all know what they say about assuming, don't we?

  4. #4
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,716

    Default

    That is really odd. I have never had to do that on a WH cPanel account. Also the directives you described in your .htaccess had to already be configured elsewhere or the pre-installed scripts would not have worked. Did you send in a support ticket on this issue? I would even now that you have it working because something seems odd and maybe there is an underlying issue that WH needs to look at on your account.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  5. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    4

    Default

    Quote Originally Posted by wildjokerdesign View Post
    That is really odd. I have never had to do that on a WH cPanel account. Also the directives you described in your .htaccess had to already be configured elsewhere or the pre-installed scripts would not have worked. Did you send in a support ticket on this issue? I would even now that you have it working because something seems odd and maybe there is an underlying issue that WH needs to look at on your account.
    I'll do that.

  6. #6
    Moderator ifurniss's Avatar
    Join Date
    Oct 2009
    Location
    Utah
    Posts
    47

    Default

    Sounds like you got things worked out, but we can definitely assist more through a ticket on this matter.
    Isaac Furniss
    Technical Support Team Manager
    Contact Support: E-mail | Live Chat | Twitter

    http://www.westhost.com/

  7. #7
    Junior Member
    Join Date
    Feb 2012
    Posts
    4

    Default

    Quote Originally Posted by ifurniss View Post
    Sounds like you got things worked out, but we can definitely assist more through a ticket on this matter.
    Done. It's ticket #552694.

  8. #8
    Member
    Join Date
    Aug 2008
    Location
    Odessa
    Posts
    30

    Default Update on CGI problem

    Awesome! I've been struggling with this for hours. Adding:

    Options ExecCGI Includes
    SetHandler cgi-script

    to the htaccess file fixed the problem like magic --thanks!

    -------------------------------------------------------

    Well, it turns out that while adding those 2 lines to the htaccess file in the main directory did cause the shtml files to work and pull text from files in the cgi-bin like they're supposed to, it caused the standard html pages to stop working! I guess I need to study this when I have time and not rush things.
    Last edited by Lucky; 04-02-2013 at 06:57 PM.

  9. #9
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,716

    Default

    .shtml is a different handler then .cgi files. You are looking fro SSI or server side include I think. The thing is this should be already set up for you. Not what may be happening is that if you put your .shtml files in the main web root of your site and then the ones you want included in the cgi-bin there may be something about the cPanel setup that keeps that from happening. the cgi-bin is for perl or cgi scripts not for files you would want included vie SSI or files with the .shtml

    If you can give some more details on what you are trying to do with examples (even if you cut out the bulk of content in files) I should be able to help you out.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  10. #10
    Member
    Join Date
    Aug 2008
    Location
    Odessa
    Posts
    30

    Default

    Hi Shawn,
    They should be paying you for all the help you dole out! BTW, the rack builder is still running strong. It will eventually be moved to this new VPS but that's a project for another day.

    My problem now is that my page at which is in the main directory (not cgi-bin) has a line in it that calls for text to be inserted on a rotating basis, a new block of text every day. That line is:

    <!--#include virtual="/cgi-bin/rotate.cgi" -->

    the script named in the line above (permission 755) works with 2 other files which are also in the cgi-bin and somehow sends the appropriate block of text back to the shtml page.

    the other files are rotate.txt (holds all the text, 744)
    and rotate_data.txt (a file for temporary storage, 766)

    I am pretty sure that the paths and permissions are correct because when I inserted the two lines mentioned above into the htaccess file, it worked! And so did the rest of the series that function similarly. The problem (other than not really knowing what I'm doing) is that it made the normal static html pages STOP working! If I was smart I could probably figure this out but I'm working this week and don't have time yet to look at this indepth. And somehow I suspect that no matter what I do, there's some secret thing that west host has to do to make it work so I just thought I would ask first. Thanks again for your kind attention.
    Ray


    I looked at the htaccess file for the old site --in fact I copied it --but there's nothing in it to allow this kind of action.
    Last edited by Lucky; 07-30-2013 at 10:35 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •