Bash scripting > html file not rendering correctly

EOM

Senior member
Mar 20, 2015
479
14
81
[RESOLVED]

[SOLUTION]
I'm an idiot and typed in the wrong filename for output.... solution is to check the filenames.


I'm hoping I'm missing something stupid.... i've written an insanely simple shell script to create an HTML page from a directory full of JPGs. It literally just displays the image and some parsed output from exiftool. I can see the output of the script looks fine from the terminal, yet when viewed in firefox, it doesn't render correctly. the <pre> tag is gone. I've tried using just <br> but to no avail either.
2helg69.png

left is what firefox is reading, and on the right is a "cat test.html" from the server..... something isn't lining up.

Code:
#!/bin/bash

arra1=(*.JPG)
#echo ${#arra1[@]}
#echo ${arra1[@]}
echo '<html><head><title>Test</title></head><body>'
echo '<h1>Testing script</h1>'
for file in *.JPG
   do convert $file -auto-orient -limit memory 4MB -limit map 8MB -resize 40% $file
done
chmod 705 *.JPG

for (( idx=${#arra1[@]}-1 ; idx>=0 ; idx-- ))
do
 echo '<img src="'${arra1[idx]}'"><p>'
cameramodel=$(exiftool ${arra1[idx]} | grep "Camera Model Name")
lensid=$(exiftool ${arra1[idx]} | grep "Lens ID") 
focallength=$(exiftool ${arra1[idx]} | grep "Focal Length")
aperture=$(exiftool ${arra1[idx]} | grep "Aperture")
shutterspeed=$(exiftool ${arra1[idx]} | grep "Shutter Speed")
isosetting=$(exiftool ${arra1[idx]} | grep "ISO Setting")
echo '<pre>'
echo "$cameramodel"
echo "$lensid"
echo "$focallength"
echo "$isosetting"
echo "$shutterspeed"
echo "$aperture<br>"
echo '</pre><hr>'
done

echo '</body>'
echo '</html>'
 
Last edited:

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Your 'img' and your 'p' tag do not have a matching closing tags so your HTML structure is not valid.

You probably meant to have something similar to
Code:
<img src="junk"></img>
<p> <pre> "EXIF Data goes here" </pre> </p>
<hr />
being spit out by each loop iteration
 

EOM

Senior member
Mar 20, 2015
479
14
81
Your 'img' and your 'p' tag do not have a matching closing tags so your HTML structure is not valid.

You probably meant to have something similar to
Code:
<img src="junk"></img>
<p> <pre> "EXIF Data goes here" </pre> </p>
<hr />
being spit out by each loop iteration

edited it to include the closers. Here is the result of each.
Code:
<img src="DSC_0118.JPG"></img><p>
<pre>
Camera Model Name               : NIKON D3200
Lens ID Number                  : 159
Lens ID                         : AF-S DX Nikkor 35mm f/1.8G
Focal Length                    : 35.0 mm
Min Focal Length                : 35.6 mm
Max Focal Length                : 35.6 mm
Focal Length In 35mm Format     : 52 mm
Focal Length                    : 35.0 mm (35 mm equivalent: 52.0 mm)
ISO Setting                     : 800
Shutter Speed                   : 1/50
Exposure Program                : Aperture-priority AE
Max Aperture Value              : 1.7
AF Aperture                     : 1.8
Max Aperture At Min Focal       : 1.8
Max Aperture At Max Focal       : 1.8
Effective Max Aperture          : 1.8
Aperture                        : 1.8
</pre></p><hr />
</body>
</html>

still not rendering properly: heres what firefox sees.... still...

Code:
<img src="[URL="http://forums.anandtech.com/view-source:http://191.101.3.196/DSC_0156.JPG"]DSC_0156.JPG[/URL]"><p> Camera Model Name               : NIKON D3200 Lens ID Number                  : 159 Lens ID                         : AF-S DX Nikkor 35mm f/1.8G Focal Length                    : 35.0 mm Min Focal Length                : 35.6 mm Max Focal Length                : 35.6 mm Focal Length In 35mm Format     : 52 mm Focal Length                    : 35.0 mm (35 mm equivalent: 52.0 mm) ISO Setting                     : 800 Shutter Speed                   : 1/20 Exposure Program                : Aperture-priority AE Max Aperture Value              : 1.7 AF Aperture                     : 1.8 Max Aperture At Min Focal       : 1.8 Max Aperture At Max Focal       : 1.8 Effective Max Aperture          : 1.8 Aperture                        : 1.8 <hr>
with no <pre> in sight....
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,815
75
So, when output from the bash script the <pre>s are there, but when viewed in the web browser the <pre>s are gone? Are they there if you look at a file:/// URL? What web server are you using?
 

EOM

Senior member
Mar 20, 2015
479
14
81
FML.....

nevermind.

i had it outputing the script to test1.html and i kept refreshing on my first try of test.html

it works fine.

Thanks guys!
 
Last edited: