I have a script in cgi-bin which gathers information from the user
and replaces placeholders in a pre-written html page with the data
collected via a different html interface. Since the script needs to
run from various servers I don't want to use absolute URIs for the
images, css file etc. and I can't work out how to get relative
pathnames to work. I'd be grateful for the solution to this problem,
which I imagine will appear very obvious once I know the answer.
JD
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Relative URIs in served pages
am 01.06.2011 17:28:28 von dermot
On 1 June 2011 16:20, John Delacour wrote:
>
> I have a script in cgi-bin which gathers information from the user and
> replaces placeholders in a pre-written html page with the data collected =
via
> a different html interface. =A0Since the script needs to run from various
> servers I don't want to use absolute URIs for the images, css file etc. a=
nd
> I can't work out how to get relative pathnames to work. =A0I'd be gratefu=
l for
> the solution to this problem, which I imagine will appear very obvious on=
ce
> I know the answer.
I'd imagine URI's rel method would work well for you in this situation.
http://search.cpan.org/dist/URI/URI.pm
HTH,
Dp.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Relative URIs in served pages
am 03.06.2011 18:11:13 von Brandon McCaig
On Wed, Jun 1, 2011 at 11:20 AM, John Delacour wro=
te:
> I have a script in cgi-bin which gathers information from the user and
> replaces placeholders in a pre-written html page with the data collected =
via
> a different html interface. Â Since the script needs to run from vari=
ous
> servers I don't want to use absolute URIs for the images, css file etc. a=
nd
> I can't work out how to get relative pathnames to work. Â I'd be grat=
eful for
> the solution to this problem, which I imagine will appear very obvious on=
ce
> I know the answer.
It would probably help if you could show us a simple example of what
you're trying and what is wrong with it. :) I'm not sure I entirely
understand what you're doing. If you're just returning
href=3D"blah" /> and tags to the user agent then
relative paths should work fine, as long as the path in the tags is
relative to the current Web page.
For example, if the current Web page is http://foo/bar/baz.html and it
references css/main.css and images/logo.png then those files should
exist as http://foo/bar/css/main.css and
http://foo/bar/images/logo.png on the server. :)
It doesn't sound like a Perl problem, but an HTML/server problem. :)
Please elaborate. :)
--=20
Brandon McCaig
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software
..org>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Relative URIs in served pages
am 03.06.2011 19:14:27 von John Delacour
At 12:11 -0400 03/06/2011, Brandon McCaig wrote:
>It would probably help if you could show us a simple example of what
>you're trying and what is wrong with it. :)...
>
>For example, if the current Web page is http://foo/bar/baz.html
I made it clear that I am serving the page dynamically from cgi-bin.
Here is an example:
The image resides in the images/ directory within cgi-bin/.
Here is the script. The image does not appear.
#!/usr/local/bin/perl
use strict;
use CGI qw~:standard~;
my $full_url= url(-full=>1);
print "Content-type: text/html;charset=utf-8\n\n";
while (){
s//$full_url/;
print;
}
__DATA__
$full_url:
Image from cgi-bin/images/:
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Relative URIs in served pages
am 05.06.2011 04:33:10 von Brandon McCaig
On Fri, Jun 3, 2011 at 1:14 PM, John Delacour wrote:
> I made it clear that I am serving the page dynamically from cgi-bin. Here is
> an example:
That part is irrelevant though because the image file is loaded by the
user agent AKA Web browser.
>
And http://bd8.com/cgi-bin/images/test.jpg fails to download. Instead
I get an internal server error (HTTP 500). That is your problem. It
isn't Perl related. Maybe the server refuses to serve the image from
within the cgi-bin directory for security reasons? Perhaps you should
move the images into a separate document root and give an absolute
path e.g., http://bd8.com/images/test.jpg.
--
Brandon McCaig
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Relative URIs in served pages
am 05.06.2011 22:01:43 von John Delacour
At 22:33 -0400 04/06/2011, Brandon McCaig wrote:
>On Fri, Jun 3, 2011 at 1:14 PM, John Delacour wrote:
>> I made it clear that I am serving the page dynamically from cgi-bin. Here is
>> an example:
>
>That part is irrelevant though because the image file is loaded by the
>user agent AKA Web browser.
On the contrary, it seems it is not irrelevant at all.
>>
>And http://bd8.com/cgi-bin/images/test.jpg fails to download. Instead
>I get an internal server error (HTTP 500). That is your problem.
And likely to be the problem of most people attempting the same thing.
> Maybe the server refuses to serve the image from
>within the cgi-bin directory for security reasons?
> Perhaps you should move the images into a separate document root
>and give an absolute path e.g., http://bd8.com/images/test.jpg.
Well, since the whole matter of the request was the use of relative
paths, for reasons I've already explained, I am not likely to find
that recommendation very useful. Indeed I can move the file to [doc
root]/images/ and link to it as ../images/test.jpg, which I have
done, but the answer to my question, in case anyone else is
interested, seems to be that httpd.conf needs to be specially
configured to regard files in cgi-bin to be regarded as
non-executables, and since I do not have access to httpd.conf on
remote servers I cannot serve images from anywhere within cgi-bin.
JD
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/