Nothing but 500 internal server error with cgi


#1

I have tried using several image upload scripts and i always get the internal server error. I was told that i could just create a folder and it would be cgi enabled. So i created cgi-bin. if anyone could tell me if this is right or why i keep getting the error that would be great. even better if someone could give me a script that works with dreamhost

i placed this script

#!/usr/bin/perl
use strict;
use CGI ":all";
print header(), start_html(), "Hello World", end_html();

into a notepad document and saved it as hello.cgi then uploaded it to nicktenhulzen.com/cgi-bin using smartftp in acsII mode and i get the same server error. i’ve set the chmod to 755 or 777. so maybe the problem isnt just my uplaod script.

here is the script i edited and below it is how it came

# START USER EDITS

# absolute path to folder files will be uploaded to.
# WINDOWS users, your path would like something like : images\\uploads
# UNIX    users, your path would like something like : /home/www/images/uploads
# do not end the path with any slashes and if you're on a UNIX serv, make sure
# you CHMOD each folder in the path to 777

$dir = "/uploads";  
#$dir = "/uploads";

# absolute URL to folder files will be uploaded to
$folder = "/uploads";

# maximum file size allowed (kilo bytes)
$max = 100000000000;

# for security reasons, enter your domain name. 
# this is so uploads may only occur from your domain
# enter any part of your domain name, or leave this 
# blank if you don't mind other web sites using your copy
$domain = "http://www.nicktenhulzen.com";

# if a file is successfully uploaded, enter a URL to redirect to.
# leave this blank to have the default message printed. If using
# this var, it must begin with http
$redirect = "http://www.nicktenhulzen.com/uploadsub.htm";

# if you would like to be notified of uploads, enter your email address
# between the SINGLE quotes. leave this blank if you would not like to be notified
$notify = '';

# UNIX users, if you entered a value for $notify, you must also enter your
# server's sendmail path. It usually looks something like : /usr/sbin/sendmail
$send_mail_path = "";

# WINDOWS users, if you entered a value for $notify, you must also enter your
# server's SMTP path. It usually looks something like : mail.servername.com
$smtp_path = "";

# set to 1 if you would like all files in the directory printed to the web page
# after a successful upload (only printed if redirect is off). Set to 0 if you 
# do not want filenames printed to web page
$print_contents = 0;

# allow overwrites? 1 = yes, 0 = no (0 will rename file with a number on the end, the 
# highest number is the latest file)
$overwrite = 0;

# file types allowed, enter each type on a new line
# Enter the word "ALL" in uppercase, to accept all file types.
@types = qw~

ALL
txt
jpeg
jpg
gif

~;

####################################################################
#    END USER EDITS
####################################################################

here it is before i messed with it

# START USER EDITS

# absolute path to folder files will be uploaded to.
# WINDOWS users, your path would like something like : images\\uploads
# UNIX    users, your path would like something like : /home/www/images/uploads
# do not end the path with any slashes and if you're on a UNIX serv, make sure
# you CHMOD each folder in the path to 777

$dir = "/path/to/demo_uploads";  
#$dir = "d:\\html\\users\\html\\images";

# absolute URL to folder files will be uploaded to
$folder = "http://www.yourserver.com/demo_uploads";

# maximum file size allowed (kilo bytes)
$max = 100;

# for security reasons, enter your domain name. 
# this is so uploads may only occur from your domain
# enter any part of your domain name, or leave this 
# blank if you don't mind other web sites using your copy
$domain = "";

# if a file is successfully uploaded, enter a URL to redirect to.
# leave this blank to have the default message printed. If using
# this var, it must begin with http
$redirect = "";

# if you would like to be notified of uploads, enter your email address
# between the SINGLE quotes. leave this blank if you would not like to be notified
$notify = 'you@yourserver.com';

# UNIX users, if you entered a value for $notify, you must also enter your
# server's sendmail path. It usually looks something like : /usr/sbin/sendmail
$send_mail_path = "/usr/sbin/sendmail";

# WINDOWS users, if you entered a value for $notify, you must also enter your
# server's SMTP path. It usually looks something like : mail.servername.com
$smtp_path = "mail.yourserver.com";

# set to 1 if you would like all files in the directory printed to the web page
# after a successful upload (only printed if redirect is off). Set to 0 if you 
# do not want filenames printed to web page
$print_contents = 1;

# allow overwrites? 1 = yes, 0 = no (0 will rename file with a number on the end, the 
# highest number is the latest file)
$overwrite = 0;

# file types allowed, enter each type on a new line
# Enter the word "ALL" in uppercase, to accept all file types.
@types = qw~

txt
jpeg
jpg
gif

~;

####################################################################
#    END USER EDITS
####################################################################

#2

I tried the hello world script and got a 403. At least it runs from command line. Here’s a wiki article on the subject:
http://wiki.dreamhost.com/index.php/KB_/Web_Programming/_CGI,PHP&_Databases#What_is_an_internal_server_error.2C_and_why_doesn.27t_my_CGI_work.3F

-Scott


#3

so maybe the problem isnt just my uplaod script.

I tried the hello world script and got a 403.

Your hello script works for me. I copy-pasted into vim. :slight_smile:

How are the directory permissions? You need 755 all the way up (or down).

What do you get for a browser request for just the directory? If you put index.html there, does it display correctly? If not, it’s a directory permission problem.

If hello world don’t work, nothin will.

tor.eff.org


#4

well i changed the chmod of the directory to 755 from 777 and now the hello works. my uplaod script still doesnt work so i still need help with that i guess

I think this may be where my problem is. below is the one i edited along with the origonal

absolute path to folder files will be uploaded to.

WINDOWS users, your path would like something like : images\uploads

UNIX users, your path would like something like : /home/www/images/uploads

do not end the path with any slashes and if you’re on a UNIX serv, make sure

you CHMOD each folder in the path to 777

$dir = “/uploads”;
#$dir = “/uploads”;

absolute URL to folder files will be uploaded to

$folder = “Http://nicktenhulzen.com/uploads”;

absolute path to folder files will be uploaded to.

WINDOWS users, your path would like something like : images\uploads

UNIX users, your path would like something like : /home/www/images/uploads

do not end the path with any slashes and if you’re on a UNIX serv, make sure

you CHMOD each folder in the path to 777

$dir = “/path/to/demo_uploads”;
#$dir = “d:\html\users\html\images”;

absolute URL to folder files will be uploaded to

$folder = “http://www.yourserver.com/demo_uploads”;


#5

Sometimes you will get these errors when you upload the cgi files via FTP. What I do when I get these errors is to log in via SSH and use pico to open the file with pico -w filename.cgi (.pl) and add a space or character to the top or bottom and then delete the space or character to cause the file to be modified. Then save and close with control-o and control-x and the 500 error should be gone, providing the permission has been set to 577 of course to make it executable.


Norm

Opinions are my own views and not the views of DreamHost. :open_mouth:
Any advice offered by me should be acted upon at your own risk.


#6

You can get this error if you coded the file using a windows text editor. Perhaps your text editor has a setting to save in unix format?

If not editing in pico as per the post above will work


#7

so did you guys not see anything wrong with my code? I used another one that i got the transfer complete thing but the files are no where to be found. If you guys could look over my code that would be great


#8

Your paths need to be something like:
/home/USER/domain.com/uploads

The script you posted references /uploads, which is in the root directory of the server, and not in your home directory.

In fact, that doesn’t look like a script. It looks more like a config file. What’s it from? Looking at your site, it appears that you’re using FrontPage. If this is FrontPage specific, I’d have to guess at solutions since I don’t use it.

-Scott


#9

alright, i finally got it working. the files needed can be found at www.nicktenhulzen.com/cgi-bin , you will need to edit the xuploadconfig file to reflect your server. the html file can be found at www.nicktenhulzen.com/upload_form.html . you will need to edit that also to point to your cgi file

there is one thing i would like to do though instead of www.nicktenhulzen.com/upload_form.html opening up a popup window with the status, i would like it to just open that status page in the same window, then redirect to a page of my choice. can someone tell me how to do this?


#10

Ah! You’re using Xupload? According to their site, only the Pro version allows an inline status instead of the popup.

And according to their site, there’s no filesize limit. Nice!

-Scott


#11

Its not what i was origionally using, but i switched to it when i found out that you can in fact upload more than 1 file at a time by just copy and pasting the “send file” script in the html file!


#12

im having problems with it displaying in firefox properly. There is a frame type outline around it and it causes it to display funny with all the upload windows i have

http://nicktenhulzen.com/uploadtest1.htm

any fix for this?

also my temp folder is deleted after a few minutes rendering the uploads usless! There is a time limit set for the files to remain in the folder that is like 24 hours but the folder deletes much quicker then that. Maybe just put a file with no chmod attributes in that folder?


#13

The page has a Style header with some irritations:
body width of only 400px. Try bumping it up to at least 600
body also has a border 1px wide solid, with a color set.

I like the frame, but if you want to get rid of it eliminate the border: and its parameters. I’d suggest changing the body width first before deleting the border, and see how you like it.

Where’s your temp folder?

-Scott


#14

I looked for that but somehow missed it. I changed to to 700 and now it looks great, thanks.

The temp folder was in my cgi-bin folder. I even tried naming it another folder besides temp. I guess i will try it in another folder


#15

Your link at the top of your upload page has your domain spelled incorrectly. Yep, nosy me.

-Scott