#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    nyc
    Posts
    2
    Rep Power
    0

    have script that keeps exiting with errors (<defunct> in top), but not in error log


    I had to keep that subject title short but here I can fully explain myself:

    I'm not new to Perl (though I am new to DevShed), I can write a script for whatever I need. However, recently I've discovered that a handful of my scripts are coming up as <defunct> in top, which means that they are not exiting properly. The scripts that are coming up with errors in the error log I can debug, but there are a few scripts that have errors that don't come up at all...anywhere. These scripts still come up in top as <defunct> though. If somebody could take a look at the following code and tell me if they see any errors (subtle technical errors that somebody like me wouldn't know) or if there is something that I don't know about that causes scripts to go defunct I'd be grateful. This code is incomplete so if you're looking at it and say "This does absolutely nothing!" I know. Also, try not to laugh at my novice coding skills.

    Thank so much in advance,
    dran

    Code:
    #!/usr/bin/perl
    use CGI ':standard';
    
    print "Content-type: text/html\n\n";
    
    #if form is submitted
    if (param('submit')) {
    $entered_email = lc(param('teacher_email'));
    
    #if the entered email is properly formatted
    	if ($entered_email =~ /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/) {
    
    #search through all email data files for the email that was entered in the form
    	my $teacher_email=qx(grep -i "$entered_email" data/*.email.txt);
    
    #if the entered email is in one of the data files
    #split up the resulting ($teacher_email) to get the email address and the username from the filename
    #note:$teacher_email is formatted as such: (below)
    #data/username.email.txt:email_address
    #where username is the username of the teacher and email_address is the email address taken from the data file
    		if ($teacher_email) {
    			@email_parts=split(/:/,$teacher_email);
    			@file_parts=split(/\//,$email_parts[0]);
    			@usr_parts=split(/\./,$file_parts[1]);
    			$teacher_email = $email_parts[1];
    			$teacher = $usr_parts[0];
    #or else, if the email is not in one of the data files (it is not the correct email), print an error message
    		} else {
    			print "That e-mail does not match our records.";
    		}
    #or else, if the email is not correctly formatted, print an error message
    	} else {
    	print "The e-mail you've entered is incorrectly formatted. Please resubmit it in <b>username\@domain.com</b>. <a href=\"forgotpwd.pl\">Go Back</a>.";
    	}
    
    #or else, if the form was not submitted, print the form
    } else {
    print qq~
    Enter the e-mail address associated with your account:
    <form method="post" action="forgotpwd.pl">
    <input type="text" name="teacher_email" />
    <input type="submit" name="submit" value="Submit" />
    <input type="hidden" name="submit" value="submit" />
    </form>
    ~;
    }
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    South Florida
    Posts
    30
    Rep Power
    15
    Does this script work at least some of the time? If not, then try running it on the command line ie. perl myscript.cgi and check for errors.

    If it does work at least some of the time, but permaturely terminates or hangs out there then try upping the limits in httpd.conf.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    nyc
    Posts
    2
    Rep Power
    0
    thanks for the quick reply....

    the script works everytime but every time i check top it comes up as <defunct> ...though there are no errors when i run it on the cmd line.

IMN logo majestic logo threadwatch logo seochat tools logo