Jump to content
xisto Community
szupie

Cgi Does it work for anyone?

Recommended Posts

I don't know why, but I just can't get my CGI stuff to work! I even tested the most basic perl script which says

print "Hello!";
, but it still doens't work! Any file, even txt files, put in my /public_html/cgi-bin/ directory gets a 500 Internal Server Error. Do I have to configure my cgi-bin in my cpanel? Is /public_html/cgi-bin/ the right directory? Does CGI work for anyone here?

So many questions, so little time...

Share this post


Link to post
Share on other sites

Szupie-
First, find your path to Perl. This can be found on the cpanel main page in the left vertical box under general server info. Then substitute that into the following code.

#!/usr/bin/perl  #this should take the format of "#!yourpathtoperl" without the quotesprint "Content-type: text/html\n\n";  #needed to indicate the start of page outputprint "Hello!";  #print output on the page

Also, the default permissions of a file are 644, (User: Read and Write, Group: Read, World: Read). Be sure to change this to 755 (User: Read, Write, and Execute, Group: Read and Execute, World: Read and Execute).

Share this post


Link to post
Share on other sites

Those were the things that I have done before, but still got the Error 500. I strongly don't think that it's the problem with my scripts, because even plain txt files fail to execute in the cgi-bin. I think that it must be something with the configuration. Does Perl work for you here?

Share this post


Link to post
Share on other sites

I run a cgi guest book in perl and it works fine. In the past I found that the local path was slightly different with some servers and that was the main problem I had with getting scripts to work.I have a little program called testmy.cgi that is placed in the cgi-bin to test scripts for you. I will be happy to give you a copy. It was freeware when it came out, but it was merged with another program the guy wrote and marketed.

Share this post


Link to post
Share on other sites

Hey.. if you cant find perl - try this command: which appname

CONSOLE

 

shell> which perl

/usr/bin/perl

 

 

As you can see from the above example it'll clearly point you to the directory in which the app exists. Usually all perl scripts need one line (the first line in the script, see vizskywalkers example) that points to the perl interpreter.. the line somewhat looks like this:

#!/usr/bin/perl

Even if you see that comment sign (#) at the beginning of this line, do not remove it. It's needed. This lines tells where to locate perl and as I said, has to be the first line in any perl script. Make sure this points to the right location of perl else your script wont work.

Share this post


Link to post
Share on other sites

Hmm... I don't have shell access to my account yet, so I can't do that... And I did find Perl on the left side onf my Cpanel. I wonder why only trekkie and I can't get our Perl to work...

Share this post


Link to post
Share on other sites

Hmm... I don't have shell access to my account yet, so I can't do that... And I did find Perl on the left side onf my Cpanel. I wonder why only trekkie and I can't get our Perl to work...

<{POST_SNAPBACK}>


chmod 755 all .cgi .pl scripts, use .pl extension and upload as ASCII.

chmod 755 cgi-bin

 

#!/usr/bin/perlprint "Content-Type: text/html\n\n";print "Hi";

Share this post


Link to post
Share on other sites

... Nope, still the same error. I've done chmod everytime after I upload my cgi and perl files, and check that it was done in ASCII mode. Is there something that I don't understand? Do these posts have some meaning in them that I don't see? They all seem really similar, but not really helping to solve my problem... Thanks for all the help...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.