Welcome to Dream.In.Code
Become an Expert!

Join 149,503 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,380 people online right now. Registration is fast and FREE... Join Now!




Corrupt *.xls file from CGI perl script

 
Reply to this topicStart new topic

Corrupt *.xls file from CGI perl script

redcat2k2
31 Jul, 2007 - 12:11 AM
Post #1

New D.I.C Head
*

Joined: 30 Jul, 2007
Posts: 2


My Contributions
I'm not sure which part of the code causes the problem, but I'm using print and printf perl commands, many times, like this:
[code]
if ($DisordersCheckbox) {
push (@UserRequiredFields, 4);
printf $typedOutFile "%s\t",$omim;
}

if ($TremblCheckbox) {
push (@UserRequiredFields, 51);
printf $typedOutFile "%s\t",$trembl_id;
}

if ($SwissProtCheckbox) {
push (@UserRequiredFields, 7);
printf $typedOutFile "%s\t",$swissprot_id;
}
[code]

the output handle is defined like this:
[code]
if ($mode eq "com_line") {
open (RESFILE, ">$outfile") or die ("Can't open outfile >$outfile<");
$typedOutFile = *RESFILE;
}
else { $typedOutFile = *STDOUT; }
[code]

executing this from the web, opens an empty file (well, it has the headers line, but not the 500 lines of data I requested).
If I then save this file and check its properties (see attachment), I get "size 70b; size on disk 14KB";
and if I ftp this file to an UNIX server I can see the data I expect, in the format I expect, with no obvious weird characters, empty lines or white spaces...
also, this hapens on only 2 of our 4 servers, the others work perfect (...); and it only hapens when I request more than 300 lines of info.
I have users all over the world that report this error, so it's not my own PC that's the fault (although I'd love it, if it were winXP's problem).

can anyone give me an idea at least where to start checking what is producing this error? if anyone knows what the error is, that would be ideal :-)



Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Corrupt *.xls File From CGI Perl Script
31 Jul, 2007 - 01:54 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
Could it be a problem with line endings? Sometimes I need to convert my code to a different type of line ending for it to work properly. Maybe your output from the script has a type of line ending that Windows doesn't like.
User is offlineProfile CardPM
+Quote Post

KevinADC
RE: Corrupt *.xls File From CGI Perl Script
31 Jul, 2007 - 10:41 AM
Post #3

D.I.C Head
Group Icon

Joined: 23 Jan, 2007
Posts: 238



Thanked: 6 times
Dream Kudos: 50
My Contributions
I'm not sure where the problem is but using printf seems completely unecessary, "%s" format is just a string and you add a tab. You can do it like this:

print $typedOutFile "$swissprot_id\t";

Are you sure you want to open the file for creating/overwriting ">" instead of creating/appending ">>" ?
User is offlineProfile CardPM
+Quote Post

redcat2k2
RE: Corrupt *.xls File From CGI Perl Script
31 Jul, 2007 - 09:34 PM
Post #4

New D.I.C Head
*

Joined: 30 Jul, 2007
Posts: 2


My Contributions
QUOTE(KevinADC @ 31 Jul, 2007 - 11:41 AM) *

I'm not sure where the problem is but using printf seems completely unecessary, "%s" format is just a string and you add a tab. You can do it like this:

print $typedOutFile "$swissprot_id\t";

Are you sure you want to open the file for creating/overwriting ">" instead of creating/appending ">>" ?


thanks for trying, but I used regular print as well, and the outcome was the same.
and yes, I'm sure the file should be created or overridden - it's the user's info, and the management of that info should be the user's as well.
cheers

User is offlineProfile CardPM
+Quote Post

KevinADC
RE: Corrupt *.xls File From CGI Perl Script
31 Jul, 2007 - 09:45 PM
Post #5

D.I.C Head
Group Icon

Joined: 23 Jan, 2007
Posts: 238



Thanked: 6 times
Dream Kudos: 50
My Contributions
OK, well, I don't know what could be the source of the problems you described. Maybe asking on www.perlmonks.com will get you some insight.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:43PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month