PDA

View Full Version : cgi problem....



coolguy23
April 1st, 2001, 15:34
...what am i doing wrong....


#!/usr/bin/perl

$image = $ENV{'QUERY_STRING'};
$directory = "C:\WINDOWS\Desktop\mysite\bspics\BSpics\";

print "Content-type: text/html";
print "<img src=$directory/$image>";


i chmoded the script to 755 and i still get a 500 error?

http://imagine.netfirms.com/cgi-bin/display.cgi?122.jpg

lucifer
April 1st, 2001, 15:50
change print "Content-type: text/html\n\n";

otherwise your <img>... is part of the header

coolguy23
April 2nd, 2001, 00:07
still no good ... :(

Koolguy
April 2nd, 2001, 00:29
print "Content-type: text/html"\n\n;

maybe, i dunno

lucifer
April 2nd, 2001, 10:52
is perl at

/usr/bin/perl ?

possible cause

check your error.log for details of the error

gyrbo
April 2nd, 2001, 12:35
Yeh, change the path, if you use windows, you need to pint it to an executable (perl.exe) somewhere on your system

Canuckkev
April 2nd, 2001, 18:56
Can't you just associate .pl and .cgi with the perl.exe? Think that's all I did and it works.

But you aren't running it off your own machine, right?

Try putting "exit;" as the last line. Upload in ASCII?

coolguy23
April 2nd, 2001, 22:01
nope not running it off my own machine...it's on netfirms and i checked everything and it still won't work!!!!

Canuckkev
April 2nd, 2001, 22:22
Check if netfirms allows .cgi scripts, and not just .pl . Just a thought, but could be the problem.

Oh....how is that directory gonna work? "C:\WINDOWS\Desktop\mysite\bspics\BSpics\"
You need to replace that with the path to the directory on your server, like "/home/sites/you/bspics"

lucifer
April 3rd, 2001, 07:12
start with an easier script to check that perl is running ok. Also they may only allow cgi in certain directories

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "my god it works";

coolguy23
April 3rd, 2001, 07:33
my images are only my hd rite now and i'm gonna upload them later....oh and mygod.cgi worked!!

cgi-bin.spaceports.com/~bsvsca/mygod.cgi

lucifer
April 3rd, 2001, 08:47
it'll be the path then your server don't know what your c: drive is

lucifer
April 3rd, 2001, 11:08
ignore that last post

problem is

$directory = "C:\WINDOWS\Desktop\mysite\bspics\BSpics\";

change to
$directory = 'C:\WINDOWS\Desktop\mysite\bspics\BSpics\';

or

$directory = "C\\WINDOWS\\Desktop\\mysite\\bspics\\BSpics\\";

"" stuff gets substitutions so \things in them have special meaning eg \n

that should work

Cheap Bastard
April 3rd, 2001, 13:16
...
first you're saying it's on netfirms, and then you come tell us your mygod.cgi worked on the spaceports cgi server...

}:8) Supermoo
April 3rd, 2001, 22:14
...maybe the site moved?

coolguy23
April 4th, 2001, 11:07
sorry to confuse but i used the netfirms cgi-bin cuz if i got an error on spaceports i get like 20 popups ;) well i played around with the code and it finally worked!!!!!!


#!/usr/bin/perl

$image = $ENV{'QUERY_STRING'};
$directory = "file:\\\C:\\WINDOWS\\Desktop\\mysite\\bspics\\BSpics\\";

print "Content-type: text/html\n\n";
print "<img src=$directory/$image>";

"exit;"

now how can i add a link at the bottom that will add and subtract an id....like a link that says Next Picture and Previous Picture

thanks for all the help!

gyrbo
April 4th, 2001, 12:32
Only problem is that people that don't have the pic on their harddrive on that location can't view it!

coolguy23
April 4th, 2001, 12:47
i know that...i'm not stupid ;)
it's just to test it and get it going...how would i change the background color to black and add the links at the bottom...

lucifer
April 4th, 2001, 14:51
just print the webpage you want instead of <IMG....>

watch out for your quotes

coolguy23
April 4th, 2001, 15:47
i mean the links to go to next picture and previous picture...

Canuckkev
April 4th, 2001, 17:32
Well, you could grep the dir for the pics, then store in an array, then link them in script like this:
print "<a href='image.cgi?@array[1]'>Prev</a>";
print "<a href='image.cgi?@array[3]'>Next</a>";
But this won't work great, because the image you just displayed have end up being next or previous.