When I run the perl script it executes based on the directory /root/cgi-bin being 'current'. This is ok. I had to adjust some paths in the menu script to ne absolute and not relative but it all works. The rather rmore complex image display Javascript doesn't though.
So, the question.... how can I make the perl script work as if it was running from the site root, rather than from the cgi-bin directory (without physically moving it)?
Thanks for any advice. It seems like a simple thing but I'm a bit baffled at the moment.
John
(I want all the perl stuff to be in cgi-bin, as per standard.)
(I could work on understanding the Javascript a bit more but it works as-is and I'd rather not spend the time as it was a downloaded thing by someone else.)
Directory structure is the usual (I believe):
root - all the html is in here
/cgi-bin
/vwd-scripts - part of the Javascript stuff mentioned
/something
/something else
etc.
let's say you script is in /cgi-bin/mygallery.pl and you want it to be run as /mygallery.htm, you'd have to put something like this in a file you call ".htaccess" (without the quotes of course):
RewriteEngine On
RewriteBase /
RewriteRule ^mygallery.htm$ /cgi-bin/mygallery.pl
that way, you can call /mygallery.htm and the script in the cgi-bin will get executed. would that solve it?
It did answer my question, for which - thanks. I have learnt something and it does simplify things, in terms of hooking into the exisitng setup.
However, I now have another problem (which may have been there all the time) which is that the Javascript to display the image is not being executed. The same static page works ok, but the same html built by my perl prog does not. I substituted the fairly complex Javascript to show the image for a very simple one that simply displayed an alert, and... nothing!
I'm pretty sure that the perl-genrated page is the same as the staic, I just cut and paste the code, and just changed a couple of bits for variables. The whole idea was that it should be the same as the static pages already present. I guess something must be different though.
I don't quite follow this, as the Javascript is called and execs (or should do) on the client, yes? And the server stuff should make no difference at that stage, and as long as the page generated is correct it should make no difference where it came from? True?
I'm a bit tired now so I'm giving up - and I'll have a fresh look tomorrow.
#!/usr/bin/perl
##
## printenv -- Perl program shows environment variables
##
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s¦\n¦\\n¦g;
$val =~ s¦"¦\\"¦g;
print "${var}=\"${val}\"\n";
}
Aaaagh! I'm definitely getting some sleep now!
I don't quite follow this, as the Javascript is called and execs (or should do) on the client, yes? And the server stuff should make no difference at that stage, and as long as the page generated is correct it should make no difference where it came from? True?
absolutely. There must be a small bug that keeps the javascript from working. Did you try putting the alert()-test directly into the file? e.g.
<script language="javascript">
alert('hooray, javascript works!');
</script> If that'll do it's most likely a problem in the way you include the javascript. Also, if you're using Mozilla, try bringing up the Error Console (Ctrl + Shift + J in the old german version I'm using, should be in the Tools-menu, at least I think it's called Tools in the english versions, the one where settings etc sit), it may contain some hints.
This is a great board. I'll be back.
Thanks, John
If your JS is not executing, try using absolute paths everywhere. Example:
<script type="text/javascript" src="/js-gallery.js"></script>
Within JS, anywhere you see references to the directory containing the images, do the same thing. You may have to "chase down" the image references. For example,
document.write('<img src="'+myimgVariable+'">');
change to
document.write('<img src="/images/'+myimgVariable+'">');
The forward slash means always start at domain root. Combined with mod_rewrite, this always gives you a common place to start and will always work.
fairly impenetrable code
You do have a copy, right, not an external script reference? If you can edit it, you can fix it.
By impenetrable code I meant just difficult to understand. It is presented as a solid block of text, without formatting and white space. I'm sure I could understand it , and debug it, if I put the time in, but the original plan was to just hook into it (as it was already in use). In the event it turned out easier to just use some other image display code I already had (written by me originally) and adapt it slightly.