Re: Too little biggy problems
by The Mad Hatter (Priest) on Aug 01, 2003 at 18:16 UTC
|
- The script can't compile on the server for some reason. Run perl -c /path/to/your-script.pl on the server to see what is wrong.
- If you aren't using strict, many monks will refuse to even look at the code and try to figure out what the problem is. It is in your best interests to use strict for every Perl program you write (at least until you understand what is going on, and when it is ok not to use strict). Please read Use strict warnings and diagnostics or die.
- (Update) If something confuses you, then that is the perfect excuse to LEARN more about it. Read the docs, ask around, but don't just give up.
| [reply] [d/l] [select] |
Re: Too little biggy problems
by sgifford (Prior) on Aug 01, 2003 at 18:39 UTC
|
My favorite trick for debugging CGI scripts when you only have FTP access is to write a short shell-script wrapper like this:
#!/bin/sh -x
printf "Content-type: text/plain\n\n";
exec 2>&1
./downloads.pl
echo "Exited with status $?"
That will show you whatever errors you would see if you were running your script from the command-line on the server.
Of course, if you can look in your server's error log, that's simpler and quicker.
| [reply] |
Re: Too little biggy problems
by blue_cowdawg (Monsignor) on Aug 01, 2003 at 18:12 UTC
|
use warnings;
use strict;
use diagnostics;
to your code?
Please include your code here rather than providing a link
to the outside world... thanks.
Peter @ Berghold . Net
Sieze the cow! Bite the day!
Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.
Brewer of Belgian style Ales | [reply] [d/l] |
Re: Too little biggy problems
by ChrisR (Hermit) on Aug 01, 2003 at 18:37 UTC
|
I had a problem like that quite some time ago. This may not be the same thing though, just a thought. I was creating and testing my scripts on a windows box (unfortunately). The problem was that I was uploading them to a linux box. The line endings from windows caused compilation errors. After replacing the bogus windows line termination characters, everything worked fine. Again, this may not be the problem at all (since you didn't specify the OS of the development or production machines), it's just a thought. | [reply] |
|
I was creating and testing my scripts on a windows box (unfortunately). {snip!} After replacing the bogus windows line termination characters, everything worked fine.
OMG! I haven't worked on a Windows box to develop code
that I forgot all about that happening to me. I was
consulting for a company that their development environment
and all their version control tools were on Windows NT and
the same exact thing happened to me. So I downloaded a
X-11 server for
Windoze NT and used XDM to log onto a Solaris box
that way. Never had that issue again. (They had an analog
to their VC software on Solaris)
Peter @ Berghold . Net
Sieze the cow! Bite the day!
Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.
Brewer of Belgian style Ales
| [reply] |
|
I have a couple of notes about this problem.
If you use #!/usr/bin/perl -<options> -- The shell and perl will ignore everything after the -- including the return.
If your ftp (on both ends) is not broken, transferring the files in ASCII mode should fix up the line breaks to be the correct variety on both ends of the link as needed.
Some windows ftp clients see that the remote end is Unix and so use binary mode for everything which, of course, is not the correct behaviour.
| [reply] [d/l] |
Re: Too little biggy problems
by ido50 (Scribe) on Aug 01, 2003 at 19:05 UTC
|
Thanks guys for the comments.
About my first problem:
-blue_cowdawg: I can't run perl -c on the script. At least I think I can't. I only have FTP access. I'm not using, strict, warnings or diagnostics.
-ChrisR: Thanks, but that's not it. I'm working on a unix box as needed.
-sgifford: What kinda file is that? It's not a perl program, right?
-The Mad Hatter: Again, I only have FTP access to the server so I can't run perl -c (As much as I know).
About my second problem, I'm pretty new with Perl and I guess I was just feeling comfortable without use strict. I guess now as I'm moving forward I find the need to really use it, so I guess I will read the use strict article and docs and get back to you with my second problem (If needed).
Thanks again, and I hope to get more comments about the perl -c thing. | [reply] |
|
sgifford's bit of code was a shell script. Just upload it like you would a Perl script (and put it in the same dir as your download.pl).
| [reply] |
|
I can't run perl -c on the script. At least I think I can't. I only have FTP access. I'm not using, strict, warnings or diagnostics.
Run the perl -c on your local machine if you are developing
on a linux (or unix) box. (Of course, make sure you have
the same Perl modules installed on your local box.
If there was ever a time for you to use warnings, use strict
and use diagnostics, this is one of them.
Peter @ Berghold . Net
Sieze the cow! Bite the day!
Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.
Brewer of Belgian style Ales
| [reply] |
|
The Mad Hatter: Thanks, I'll do that.
blue_cowdawg: I'm writing on windows, but writing for linux (Well, FreeBSD to be quite honest). I'll try anyway to run perl -c on the script.
And about the use strict, warnings and diagnostics pragmas, I'll read more about them and do that also.
| [reply] |
|
|
|
|
|
Re: Too little biggy problems
by Hagbone (Monk) on Aug 01, 2003 at 22:19 UTC
|
Just a FWIW ... here's something I've used when trying to get the browser to display error messages in situations where my access to tools is limited. I grabbed this from a list/group years ago, and don't pretend to be able to explain the finer points of what makes it tick....
#Put the following code at the top of the script, just below #!/usr/bi
+n/perl.
#Run the program from your browser, and read what is printed there.
BEGIN {
local($|) = 1; # Temporarily turn off bufferi
+ng
print "Content-type: text/plain\n\n";
my $date = localtime;
print "Script $0\nrunning on $date (Perl version $])\n\n";
unless (open STDERR, ">&STDOUT") {
print "Can't redirect STDERR: $!";
exit;
}
print "\n";
}
| [reply] [d/l] |