Flame has asked for the wisdom of the Perl Monks concerning the following question:
A friend asked me to throw something together for him to help him control a roster. The problem is, while what I wrote works on my server, it doesn't work on his. Now here's the real kicker though... when I cleared out one of my old files I'd gave him (old test proggie) that did work, and pasted in the code from my new program, it worked.
I've looked at the code carefuly, and it is identical... I also double checked the chmod and the path to perl, both of those are identical... so the question is... what could make this work with one file, and not with the other?
#!/usr/bin/perl
use Storable;
#use CGI qw(:standard);
use strict;
use constant ROSTER => '/storage/roster.dat';
print "Content-Type: text/html; charset=ISO-8859-1\n\n";
#print header;
my $data;
if(-e ROSTER){
$data = retrieve(ROSTER);
}
#You can edit here
#Note: Do not use the character ~ when editing without contacting some
+one with perl experience
print qq~<html>
<head>
<title>Moonglow Town Council of Atlantic - a Guild, Organization, and
+People</title>
<style type="text/css">
BODY{
scrollbar-base-color:#39428D;
scrollbar-track-color:#39428D;
scrollbar-arrow-color:#FFFFFF;
scrollbar-highlight-color:#262659;
}
</style>
</head>
<body bgcolor=black link=white alink=white vlink=white text=white back
+ground="http://www.greypawn.com/MTC/images/content_02.jpg" bgproperti
+es=fixed>
<font face=Arial size=2 color=white>
<span style="font-size:12pt;filter:Shadow(color=#000000,direction=135)
+;padding:5;width:100%;">
<h2>Member Roster</h2>
<font color=white size=2 face=Verdana><b>
<br>
<center>
<table cellspacing=0 cellpadding=0 border=0 width=500>
<tr>
<td><font face=Arial size=2 color=white><b><div align=left>Na
+me:</td>
<td><font face=Arial size=2 color=white><b><div align=left>Ti
+tle:</td>
<td><font face=Arial size=2 color=white><b><div align=left>IC
+Q:</td>
</tr>~;
#NO MORE EDITING WITHOUT SUPERVISION
#Data format:
# Hash of names
# - icq
# - title
if($data){
my @list = sort({ $a cmp $b } keys(%{ $data }));
foreach my $name (@list){
my $icq = $data->{$name}{'icq'};
my $title = $data->{$name}{'title'};
print qq~ <tr>
<td><font face=Arial size=2 color=white><b><div align=left>$n
+ame</td>
<td><font face=Arial size=2 color=white><b><div align=left>$t
+itle</td>
<td><font face=Arial size=2 color=white><b><div align=left>$i
+cq</td>
</tr>~;
}
}else{
print qq~<tr><td align="middle"><font face="Arial" size=3 color=red
+><b>Error: Unable to scan required data!</b></font></td></tr>~;
}
print qq~</table>
</center>
<br><br>
</font>
</span>
</body>
</html>~;
Note: I realize this code is highly unprofessional, I literally threw it together since I wanted this project done quickly... It is *not* up to my usual requirements. The HTML is also not my fault as it was copy-pasted from a template my friend had.
If you think I overlooked anything, feel free to ask.
My code doesn't have bugs, it just develops random features.
Flame ~ Lead Programmer: GMS | GMS
Re: Identical files, only one works?
by Popcorn Dave (Abbot) on Dec 08, 2002 at 05:33 UTC
|
Tadman is right with the diff idea but here's a couple more things for you.
If you're on a windows machine, I've found that sometimes rebooting the thing can make unstable code actually run -- well code that was stable and the machine wasn't. :)
The other thing to try is clear the browser cache. That has made a difference for me in the past.
Hope that helps!
There is no emoticon for what I'm feeling now. | [reply] |
|
| [reply] |
Re: Identical files, only one works?
by mbadolato (Hermit) on Dec 08, 2002 at 07:19 UTC
|
I'd recommend:
0) Verifying that you aren't transferring the file up in Binary mode (it must be ASCII). As a side note, if you're using an older version of CuteFTP, it's been found to often transfer files in Binary, even when ASCII was selected (I can't tell you how many times this was an issue with CuteFTP when I was doing tech support for a commercial Perl product).
1) Check the file format... if it's a windows file, it could be screwing up on a Unix box due to the line feed character. Transferring in ASCII should fix that
2) Check the shebang line; the path to perl could be different than what you have
3) Check file permissions to make sure you set it as executable. Also make sure the owner and group permissions are set such that the web server has execute permissions
--mark | [reply] |
Re: Identical files, only one works?
by tadman (Prior) on Dec 08, 2002 at 05:19 UTC
|
What exactly do you mean by "doesn't work"? Does it run? Produce output? Errors? Anything at all?
It could be that something went screwy when you copied it over. The only way to know for sure is to use something like diff to compare the working and non-working versions. | [reply] [d/l] |
|
| [reply] |
|
The first file was already there and running from about a year and a half ago
So, the file name (indeed, the inode) of the first file is
now being used to store the new script? Sounds more like
a server/file permission problem than a problem of script
content.
Do either you or your friend remember what was done a
year and a half ago when that first file was installed and
made to run? Are you sure you repeated the same steps this
time when trying to install a second file? Are you sure
the folks who run the server haven't changed policy since
then -- e.g. no more new cgi scripts without some additional
check/approval/blahblah? (Who knows? Maybe they put in a check to see if
a perl cgi script has "-T" on the shebang line.)
If there was a policy change, it's
possible that it applies only to new stuff, and existing
script files were allowed to continue operating.
| [reply] |
|
# ensure all fatals go to browser during debugging and set-up
# comment this BEGIN block out on production code for security
BEGIN {
$|=1;
print "Content-type: text/html\n\n";
use CGI::Carp('fatalsToBrowser');
}
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
| [reply] [d/l] |
Re: Identical files, only one works?
by Anonymous Monk on Dec 08, 2002 at 06:21 UTC
|
A random guess. One copy had DOS line endings, one had Unix. This is a problem because "/usr/bin/perl" is an executable on your system, but "/usr/bin/perl\r" isn't... | [reply] |
|
| [reply] |
Re: Identical files, only one works?
by Flame (Deacon) on Dec 09, 2002 at 01:39 UTC
|
I seem to have figured out the problem... it wasn't the cache, or the program at all for that matter... it seems that every upload has to sit around for a while before it actually runs properly... I left a broken program (that should have worked) up there and went to bed.. it worked in the morning...
My code doesn't have bugs, it just develops random features.
Flame ~ Lead Programmer: GMS | GMS | [reply] |
|
|