Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Apache 2, Perl 5.8.0, Netware 6.5 server reboots

by chriso (Sexton)
on Jun 29, 2005 at 14:57 UTC ( [id://471049]=perlquestion: print w/replies, xml ) Need Help??

chriso has asked for the wisdom of the Perl Monks concerning the following question:

I am using Apache2 on a Netware 6.5 server. At first, I had problems in that my server would reboot when I executed the following command:
open (FILE, "243q1_13.txt") || die "Cannot open $file: $!";
After I removed the (), the server no longer reboots, but it never executes the WHILE statement because the print statement, "Start of while loop", I inserted to see if the loop is accessed never gets printed. I do not get the "error" message as if the file could not be found or opened, and the statement, "$file has been opened" does get printed correctly.

I also deleted the file to be accessed from the directory and the script did not give me an error message so it appears that the script is ignoring the open statement.

This script ran fine on a Netware 5.1 server running Novell Enterprise Server, but I've had a lot of trouble running it on Apache2. Does anyone have any ideas?

Thanks for your help.

print "<H2>Hello $fullname!</H2><P>"; print start_form (-name=>'makequiz', -method=>'POST', -action=>"http:/ +/ist221.nsm.tridenttech.edu/perl/gradequiz.cgi"); open FILE, "243q1_13.txt" || die "Cannot open $file: $!"; print "$file has been opened<p>"; while (<FILE>) { # ** READS EACH LINE OF TEXT FROM FILE print "Start of while loop<p>";

janitored by ybiC: Retitle from less-than-descriptive "Why doesn't this work?", for better site-search results

Replies are listed 'Best First'.
Re: Apache 2, Perl 5.8.0, Netware 6.5 server reboots
by trammell (Priest) on Jun 29, 2005 at 15:04 UTC
Re: Apache 2, Perl 5.8.0, Netware 6.5 server reboots
by Transient (Hermit) on Jun 29, 2005 at 15:00 UTC
    While I can't tell you why your server would reboot when your script die'd (although I don't think you want to be die'ing in a CGI)... your
    open FILE, "file" || die "Cannot open $file";
    will NEVER die, because || has higher precedence. Thus, it's actually doing
    open FILE, ("file" || die "Cannot open $file");
    The parentheses you had in before prevented the || from being evaluated first.
Re: Apache 2, Perl 5.8.0, Netware 6.5 server reboots
by friedo (Prior) on Jun 29, 2005 at 15:02 UTC
    That doesn't work because the || operator has very different precedence than the "or" operator, which is what you should be using. See perlop for more information.

    open FILE, "243q1_14.txt" or die "Cannot open file: $!";

    That will at least give you an error message if something goes wrong.

Re: Apache 2, Perl 5.8.0, Netware 6.5 server reboots
by chriso (Sexton) on Jun 29, 2005 at 16:23 UTC
    Interesting. I replaced the || with "or", and ran the script and my server rebooted. Is there anything wrong with my syntax (Personally I think Netware is hosed up)? I put the file in the same directory as the scirpt. BTW, the version I'm using is perl v5.8.0 Chris
      Your server may think the current working directory is different than you. Try using an absolute path to that file and try it again. Also, examine your log file. You'll probably see the line where it aborted because it couldn't read the file. Also, also, you might want to use something like Cwd like use Cwd; warn "current working directory: " . getcwd(); just prior to that line. You'll know what the current directory is then.
        Thank you!! I did a getcwd() and lo, it was not the directory I wanted. I then did a chdir and it's doing much better.
Re: Apache 2, Perl 5.8.0, Netware 6.5 server reboots
by ybiC (Prior) on Jun 30, 2005 at 14:50 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://471049]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-28 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found