CGI hangs due to dodgy escape character 
Author Message
 CGI hangs due to dodgy escape character

Hi all,

Just moved web servers - this script used to work fine on the old one.
Basic idea is that given a directory of pictures (and a subdirectory
of thumbnails), it creates the HTML to display them.

What is happening now is that it is{*filter*} part way through the
script.  It's not very long, so here goes.

#!/usr/bin/perl -w
#
# photos.cgi v1.1 - Antony Gelberg
# Given a directory, displays photos in HTML.
#

use strict;
use CGI;
use Cwd;

my $q = new CGI;

my $dir = $q->param('dir');
my $file = $q->param('file');;

print $q->header();

# Need to be in root directory.
chdir "/var/www/antgel/html" ||
  die "Could not chdir to /var/www/antgel/html\n";

if ($dir eq "") {
  die "No directory specified in photos.cgi.";

Quote:
} else {

  if ($file eq 'thumb') {
    # We want thumbnails.
    chdir "$dir/thumbnails" || die "Could not chdir to
$dir/thumbnails\n";
    my $dirs = `ls -1`;

    my $rowsize = 5;
    my $column = 1;
    print "<TABLE>\n";

      if ($column == 1) {
        print "<TR>\n";
      }
# Fix border attribute in link to css at some point.
      print "<TD><A HREF=\"/$dir/$file\"><IMG
SRC=\"/$dir/thumbnails/$file\" BORDER=0><\A><BR>\n";
      if ($column eq $rowsize) {
        print "</TR>\n";
        $column = 0;
      }
      ++$column;
    }
    print "</TABLE>\n";
  } else {
    # We want a specific photo.
    print "<IMG SRC=\"/$dir/$file\"><BR>\n";
  }

Quote:
}

Firstly, I am sure that there are more efficient ways of doing this.
But I come from a C/Java background, and it's hard to pick up Perl
idioms when you can program in a known way.

Anyway it hangs midway through the last iteration of the loop.
Specifically if I hit stop on the browser and view source, it stops
halfway through the long print statement, just before the </A>.

The only light I can shed on it is the error that I get -
"Unrecognized escape \A passed through".  I don't think this is
coincidence, but I have no clue how to fix it.  I understand that \A
might be construed as an escape character, but as it is being passed
through, I don't see why it has an effect.

Antony



Thu, 11 Aug 2005 05:40:55 GMT  
 CGI hangs due to dodgy escape character
Solved - needed to print $q->end_html.

Antony



Thu, 11 Aug 2005 05:57:40 GMT  
 CGI hangs due to dodgy escape character


Quote:
>Solved - needed to print $q->end_html.

>Antony

Problem back on.  There was actually a reason I didn't have this
originally.  My source file #includes this .cgi then #includes another
file.  Ending the HTML causes the later file not to be #included.

Do I need to flush the output or something like that?

Antony



Thu, 11 Aug 2005 06:02:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Escape Character/CGI Script Trouble

2. Formats: Escaping Characters

3. problems with the \n escape character

4. Escaping cursor characters

5. Variables and escaped characters in RegExp

6. how do I retranslate escaped characters

7. regex to escape special characters

8. Striping VT100 escape characters from a file

9. Why do escape characters show when printing?

10. Which characters need escaping list?

11. Automatically escape characters?

12. How to convert literal escape to ascii character?

 

 
Powered by phpBB® Forum Software