Web Hosting Talk







View Full Version : cgi-bin cgi/perl scripts


gthorley
10-30-2000, 09:18 PM
On my confirmation email from Tera-byte it was indicated that I would not see a cgi-bin directory and that cgi scripts could be put wherever I wanted. I am not sure what this means but am having no luck in getting a guestbook script to work. Does it mean that they have execcgi turned on? Do my .pl files need to be .cgi files? I have tried numerous paths for the following variables and nothing seems to work.

$guestbookurl = The url address of your guestbook.html file.
$guestbookreal = The system location of your guestbook.html file.
$cgiurl = The url portion of the address to the guestbook.pl file The file guestbook.pl needs to be placed in your server's cgi-bin and chmoded read/execute for users of your
httpd. (chmod a+rx)

What is the best method of tracing down the problem.

BC
10-30-2000, 09:53 PM
Uhmm.... Have you tried contacting Tera-Byte's support department first?

cbaker17
10-30-2000, 10:47 PM
Perhaps if you need help you should post the error message??

ANyways the most common problem for cgi's not working is the incorrect path to perl IE the path statement located at the very top of your cgi file.

gthorley
10-31-2000, 12:53 AM
BC
My first request this a.m was responded to but didn't solve the problem, My subsequent requests have not as yet been responded to.

I received 2 different error messages.

>CGIWrap encountered an error while attempting to execute this script:

> Error Message: Permission denied
> Error Number: 13

Then after checking some boxes to try to set the chmod I got an

> Error Message: No such file or directory
> Error Number: 2

As I write this I just received a further email reply as follows

""We don't really get into debugging scripts, but here's what I just did.

I looked on your website itself, into guestbook.pl.

The first line was #!/usr/bin/perl--

I changed it to #!/usr/bin/perl -- ""

The script still did not work but it seems to call it fron the addguest entry because if left blank I get an error message from the guestbook.pl that nothing was entered and to resubmit. With fields completed I receive the following error.

""The server encountered an internal error or misconfiguration and was unable to complete your request.""

kunal
10-31-2000, 05:38 AM
Just create a dir called "cgi-bin" without the " ". CHMOD it to 755. I presume u know how to do that? Now, put all your scripts in the cgi-bin dir. CHMOD each file to there requirments. I think 755 should be write. This should work.

As far as the Errors are concerned, I think it is because of the paths and permisions you have set for your scripts.

gthorley
10-31-2000, 10:35 AM
Thanks for your reply Kunal

Originally posted by kunal
Just create a dir called "cgi-bin" without the " ". CHMOD it to 755. I presume u know how to do that? Now, put all your scripts in the cgi-bin dir. CHMOD each file to there requirments. I think 755 should be write. This should work.

As far as the Errors are concerned, I think it is because of the paths and permisions you have set for your scripts.

Is this standard to create a cgi-bin directory? Is this directory not normally on the hosts section of the server?
If I create the directory do I create it as a sub directory to my main directory "web' which is where my index.htm file is or where?

I have figured out the CHMOD. I use WS_ftp and it just gives the settings as to read, write & execute not the numerical.
But using an old version of Cute ftp which gives the numbers which correspond I was able to understand the settings. The script file is 755. The guestbook.htm is 777 and the addguest.htm is 744.

I am sure the problem lies with the paths placed in the variables. I don't think that I am enetring them correctly.

As an example for the following :

$cgiurl= The url portion of the address to the guestbook.pl file. The file guestbook.pl needs to be placed in your server's cgi-bin

Tera-byte indicated the following info for this variable
/home/sites/www.artbyjudy.com/web/cgi-bin/

I have tried using this and different combinations.
One problem is I have no understanding of what it means ie:
-Should it be preceeded by something like "http:" or ".."
-What does /home/sites mean is this something to do with the address to the server?

Can someone explain this url and what it does?
Also can I use my IP address in place of "www.artbyjudy.com" in the urls.

kunal
10-31-2000, 11:07 AM
Is this standard to create a cgi-bin directory? Is this directory not normally on the hosts section of the server?
If I create the directory do I create it as a sub directory to my main directory "web' which is where my index.htm file is or where?


Yes, this is the standard to create a cgi-bin dir. It should normally be there, but if itsnt you can create it ;). You have to create it under the "web" directory.


As an example for the following :

$cgiurl= The url portion of the address to the guestbook.pl file. The file guestbook.pl needs to be placed in your server's cgi-bin

Tera-byte indicated the following info for this variable
/home/sites/www.artbyjudy.com/web/cgi-bin/


Try one of these
$cgiurl = "/home/sites/www.artbyjudy.com/web/cgi-bin/"
OR
$cgiurl = "http://www.artbyjudy.com/cgi-bin/"


-Should it be preceeded by something like "http:" or ".."


It depends, if the path should be the absolute path, then you dun need the "http:" or "..". The path should look like this "/home/sites/whatever"


-What does /home/sites mean is this something to do with the address to the server?


Yes, it is the absolute path the files on the server.


Also can I use my IP address in place of "www.artbyjudy.com" in the urls.

Yes, you can use your IP address. That should not be a problem at all.

Chicken
10-31-2000, 11:37 AM
Originally posted by kunal

As an example for the following :

$cgiurl= The url portion of the address to the guestbook.pl file. The file guestbook.pl needs to be placed in your server's cgi-bin

Tera-byte indicated the following info for this variable
/home/sites/www.artbyjudy.com/web/cgi-bin/


Try one of these
$cgiurl = "/home/sites/www.artbyjudy.com/web/cgi-bin/"
OR
$cgiurl = "http://www.artbyjudy.com/cgi-bin/"

The only thing I'll add, is that it seems to want the the full path to the file (if I'm not mistaken), which would be:

/home/sites/www.artbyjudy.com/web/cgi-bin/guestbook.pl

without including the file name 'guestbook.pl' you are just leading the script to your cgi-bin (I wouldn't think this would work).

kunal
10-31-2000, 11:44 AM
If it needed the absolute path, Chicken, then the filename isnt necessary, else it is.

gthorley
10-31-2000, 02:30 PM
Thanks again for the help Kunal. I have spents hours on this thing and can't seem to get it to work. The variables are set as follows.

# Set Variables

$guestbookurl = "http://216.234.185.32/guestbook/guestbook.html";
$guestbookreal = "/home/sites/216.234.185.32/web/guestbook/guestbook.html";
$guestlog = "/home/sites/216.234.185.32/web/guestbook/guestlog.html";
$cgiurl = "http://216.234.185.32/cgi-bin/guestbook.pl";
$date_command = "/usr/bin/date";

I have tried taking the /web out of $guestbookreal and setting $cgiurl to /home/sites/www.216.234.185.32/web/cgi-bin/guestbook.html
with this in it directs to
-http://216.234.185.32/home/sites/216.234.185.32/web/cgi-bin/guestbook.pl and this variable only is used when fields in the form are blank and it asks for info when resubmitted it looks for the web address along with the system address so have come to the conclusion that the url set is correct. I have come to the conclusion that the problem could only be in $guestbookreal or that the script doesn't work or that the server is not reading the script.

Oh yes and I double checked all the chmod.
cgi-bin directory and guestbook.pl I set to 755
guestbook directory and guestbook.html to 777
addguest.html to 744

Any other suggestions would be appreciated.
Is there a simple cgi/perl script or test that I can put up to make sure cgi is running on my site. The cobalt site settings indicates cgi is active.

ODE
10-31-2000, 02:56 PM
Originally posted by gthorley
""The server encountered an internal error or misconfiguration and was unable to complete your request.""

You made sure to upload the file as ASCII(text) right? I've gotten this error when I uploaded a perl script as binary.

kunal
10-31-2000, 03:04 PM
Try these
# Set Variables

$guestbookurl = "http://216.234.185.32/guestbook/guestbook.html";
$guestbookreal = "/home/sites/www.artbyjudy.com/web/guestbook/";
$guestlog = "/home/sites/www.artbyjudy.com/web/guestbook/";
$cgiurl = "/home/sites/www.artbyjudy.com/web/cgi-bin/";
$date_command = "/usr/bin/date";


You cannot put the IP address in the absolute path.

[Edited by kunal on 10-31-2000 at 02:06 PM]

gthorley
11-01-2000, 11:20 AM
Well I finally got the sucker running (somewhat). Thanks to all that assisted especially Kunal and at Tera-byte.

The main problem it appears to have been the site at not yet propagated fully and I was trying to use my IP address. As pointed out in a latter post by Kunal this is not allowed in an absolute address. It also appears the original addguest.html file included with the script did not work properly.

For the record just in case anyone using Tera-byte does a search and needs help on the variables these are what I ended up with

$guestbookurl = "http://www.artbyjudy.com/guestbook/guestbook.html";
$guestbookreal = "/home/sites/www.artbyjudy.com/web/guestbook/guestbook.html";
$guestlog = "/home/sites/www.artbyjudy.com/web/guestbook/guestlog.html";
$cgiurl = "http://www.artbyjudy.com/cgi-bin/guestbook.pl";

Problem still

The date variable $date_command = "/usr/bin/date"; doesn't seem to work. Anyone have a suggestion.

Next project a counter, hopefully I have learned enough to accomplish it.

kunal
11-01-2000, 11:27 AM
Im glad you got most of the script going ;)

Ask Tera-byte if they have the date module installed, and if they do, the path to it. I think thats your problem. I have never used the date function in this way though. :(

As far as the counter script, goes, are you writing your own or getting one? If you are getting one, get one which has some decent documentation. :)

kunal
11-01-2000, 11:29 AM
Try this,
$date_command = "#!/usr/bin/date";

gthorley
11-01-2000, 12:34 PM
Thanks Kunal it is actually "/bin/date"

Used "which date" command at unix prompt. Wish everything was that simple.

Looking at a counter program and it seems straightforward except for

#Name of Server counter is to be working on

@serverlist=("www.server1.net","www.server2.net", "css.tuu.utas.edu.au");

Any idea what these refer to? Do I need the actual name or IP of the server box I am set up on?

kunal
11-01-2000, 12:40 PM
Well, I was stumped by the guestbook script. Why dun you use PHP instead? Its much much easier to use ;)

I think that variable lets those particular hosts to only use the script. No other host will be able to use them. So I would suggest, not giving the ip's.

etLux
11-07-2000, 09:37 AM
Originally posted by gthorley
#Name of Server counter is to be working on

@serverlist=("www.server1.net","www.server2.net", "css.tuu.utas.edu.au");

Any idea what these refer to? Do I need the actual name or IP of the server box I am set up on?

That typically enumerates the servers upon which you wish to allow the script to work. If the domain name isn't in that list, then the script would not work on it.

You should include the IP number if your site is routinely addressed in that manner; otherwise, it isn't really needed.

brandonk
11-09-2000, 12:31 AM
For what it's worth:

Their using a Cobalt RaQ of some sort. Therfore their is no need to have a cgi-bin. You can place the script anywhere as they've instructed, just make sure their chmod right.

Brandon :)

etLux
11-09-2000, 01:10 AM
General Background:

Servers may *vary* in requirements for script placement, depending on configuration.

Some may require placement specifically in a folder named cgi-bin; and a few older systems may use the convention of placing scripts in a folder called -- scripts.

However, many servers are insensitive to the location of the script.

Systems functioning under CGI-Wrap can go either way; but check for designated paths, as they often require inclusionaries in the path specific to the administrator's configuration.

Extensions on scripts may also vary. In some cases .cgi is absolutely required. Other cases allow .cgi and .pl extensions. In some configurations, however, scripts may be insensitive to extension, or not even require one.

The Lesson:

Read your server documentation!

[Edited by etLux on 11-09-2000 at 12:14 AM]