Hello I'm having a bit of issue I have thrid party program that builds a JPEG(JFIF really). For some reason when I try to read it in perl binmode it removes the header information. Server code recieves plot to build and passes back the image data
print `/cwms/s0cwmsxx/v1.5.01/bin/dssVue $LINE.py /cwms/g7cwmspd/plot +Files/files/$num`; print "After command\n"; open(FH, "/cwms/g7cwmspd/plotFiles/files/$num.jpg"); binmode(FH); my $buf; while(<FH>) { read(FH,$buf,500); print $buf; print $client $buf; }
client(cgi) sends the message to build the plot and print out the image
print "Content-type: image/jpeg\n\n"; print $socket "$MESSAGE\n"; read($socket, $buffer,2097152); print "Content-type: image/jpeg\n\n"; print substr($buffer,1); open (OUTIMAGE,">/usr26/wcdb/log/plottest.jpg"); binmode(OUTIMAGE); print OUTIMAGE substr($buffer,1); close(OUTIMAGE);
Any ideas why I'm not getting the first 200 or so bytes of header information? Ie.I ftp both files one created by the thrid party program and the one from my reading it. The one created by the thrid party program starts JFIF    C  and is 77,737. Looking closely it does have The below in it. So to me it looks like for somereason binmode perl is not read maybe the header information of the JPEG? My reading starts   } !1AQa"q2#BR$3br and is 77,528 bytes and doesn't work correctly.

In reply to JPEG cgi problem by mouser13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.