Getting started on a Linux web hosted site

Started by Head for the hills, March 07, 2013, 06:20:21 AM

Previous topic - Next topic

Head for the hills

Hi,
Please excuse my noobishness with perl modules etc.
I have a Linux hosted website. Here's what I've done.
FTP'd the uncompressed Image-ExifTool-9.13 folder (and subfolders) to the root of my site.
Created a simple shtml page that contains <!--#include virtual="/cgi-bin/exif.pl"--> in the body.
Created /cgi-bin/exif.pl and chmod 755
#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";
use lib '/Image-ExifTool-9.13/lib';

use Image::ExifTool;
my $exifTool = new Image::ExifTool;

my $info = $exifTool->ImageInfo('exif.JPG');

foreach (keys %$info) {
    print "$_ => $$info{$_}\n";
}

Where have I gone wrong, and please don't just say everywhere. :-[
Any help will be much appreciated.

Phil Harvey

#1
First, see if you can get the CGI script to work without ExifTool.

Then, try one step at a time.  First just try adding your "use" statement to see if that works.  If it doesn't you have a permission problem or can't access the directory for some reason.

Then if this works, your script should work provided that you format the output in HTML.  Something as simple as this would do:

#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";
use lib '/Image-ExifTool-9.13/lib';

use Image::ExifTool;
my $exifTool = new Image::ExifTool;

$exifTool->Options(Escape => 'HTML');

my $info = $exifTool->ImageInfo('exif.JPG');

print "<html><head></head><body><pre>\n";
foreach (keys %$info) {
    print "$_ =&gt; $$info{$_}\n";
}
print "</pre></body></html>\n";


Edit: Added missing semicolon in code.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Head for the hills

Many thanks for your prompt reply Phil. I'm sorted now.

Phil Harvey

It may help others if you explained what your problem was, and post your working cgi script.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Head for the hills

There's not a lot to add really. My problem was nothing to do with exiftool, just a silly path error pointing to the library due to using subdomains.
I tested with the code you posted (just needs a semicolon on the end of one print statement).

Phil Harvey

Great, thanks.  I added the semicolon.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).