Can someone write me a very basic perl script?

notfred

Lifer
Feb 12, 2001
38,241
4
0
#!/usr/bin/perl

#Specify a filename here
$filename = "somefile.jpg";

print "Content-Type: image/jpeg\n\n";

open IMG, "$filename";
while(<IMG>){print}
close IMG;
 

AgaBoogaBoo

Lifer
Feb 16, 2003
26,108
5
81
I did that and I get an internal server error. The path to perl seems to be correct, /usr/bin/perl is what my host provided me with.

What do you think went wrong?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: AgaBooga
I did that and I get an internal server error. The path to perl seems to be correct, /usr/bin/perl is what my host provided me with.

What do you think went wrong?

Make sure the file is set executable, then check the error logs for the server to see what the actual error you're getting is.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
The script that notfred supplied has a hardcoded path to the filename. Did you change the script so that it determines the correct filename?
 

AgaBoogaBoo

Lifer
Feb 16, 2003
26,108
5
81
I tried chmodding 777 to everything and then again but with 755. Each gave the same error in the log files:

error: directory is writable by others
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
.. So make the directory not writable by others.

BTW - chmod 777 is almost never a good solution to anything.
 

AgaBoogaBoo

Lifer
Feb 16, 2003
26,108
5
81
Originally posted by: BingBongWongFooey
.. So make the directory not writable by others.

BTW - chmod 777 is almost never a good solution to anything.

I did that, using 755 to take writing permissions away from everyone but the owner.

I know 777 isn't the best solution, but I use that test when I'm having some errors
 

AgaBoogaBoo

Lifer
Feb 16, 2003
26,108
5
81
Originally posted by: oog
The script that notfred supplied has a hardcoded path to the filename. Did you change the script so that it determines the correct filename?

RIght now the problem doesn't lie in the image, but running the file
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You need to check the server's error logs, usually they'll tell you what's wrong.