The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Exim perl piping and errors

Discussion in 'General Discussion' started by sparek-3, Jan 26, 2005.

  1. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I have a perl script that I am using to pipe e-mail messages through and store in a database. The script works, and that is not the issue. I am trying to get the script setup so that if an error is detected, the person that sent the message will not receive the bounced error message. I have redirected STDERR to a file, and this works when running the script from the command line. The file also receives the error messages when the script is run through the exim pipe, however the writer receives a bounced message. I am just looking for a way to prevent exim from sending that message. Again, nothing is wrong with the script. I am just wanting to implement this in case there is something that happens that causes the script to generate an error. I read some posts pertaining to this, but did not see a fix. Has anyone been able to work around this?
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Does redirecting STDERR not work when piping? It ought to. Obviously, the best solution is to make sure that you don't generate errors :) Probably the best way is to make sure that you implement your own error routine, rather than using die and trap errors that way and handle them cleanly.

    Ways to trap fatal errors include:

    1. Using eval on statements to return control back to the script
    2. Using alarm and $SIG{'ALRM'} to trap fatal errors and return control back to your own subroutine

    Usually eval is the way to go, but I like playing with alarms - they're fun ;)
     
  3. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Thanks chirpy

    I guess the problem was, even with the errors being output in a file, the script was still returning that it exited with an error. I used the eval to get around this.

    Thanks again.
     
Loading...

Share This Page