in reply to Sendmail .forward + perl

1) How do you know for sure that the program is getting executed?

2) What user is the script running as? Does it have the correct permissions?

3) With that in mind, you should be checking the return of open (always check the returns of system calls!):

open (MAIL, ">/home/brian/mail.txt") or die "Can't open: $!"; print MAIL "\n"; while (<STDIN>) {print MAIL $_} close MAIL or die "Can't close: $!"
Is the file ever created, even? Is anything ever written to it?

Replies are listed 'Best First'.
RE: Re: Sendmail .forward + perl
by setantae (Scribe) on Mar 25, 2000 at 01:18 UTC
    I have to say it's probably number 2.
    [root@archaia /root]# su nobody [nobody@archaia /root]$ perl -e 'open (MAIL, ">./foo");print MAIL "scr +atchymonkey.\n" ;' [nobody@archaia /root]$ exit [root@archaia /root]# ls bin mod_perl_docs [root@archaia /root]#
    Note how there's no error at all, but the file isn't there.
    Let's try it with -w :
    [nobody@archaia /root]$ perl -we 'open (MAIL, ">./foo");print MAIL "sc +ratchymonkey.\n ";' print on closed filehandle main::MAIL at -e line 1.
    Hmm, what's going on there?
    [nobody@archaia /root]$ perl -we 'open (MAIL, ">./foo") || die "$!";pr +int MAIL "scrat chymonkey.\n";' Permission denied at -e line 1.
    What user does sendmail run as on your box?
    Check the open() as above...