procmail
[Top] [All Lists]

Re: FW: UPDATED: passing variables to a perl script

2000-11-27 13:16:51
On 27 Nov, Joel Dudley wrote:
| [...]
|       Here is the perl script and procmailrc file I am using to pass
| variables to. I am not really a perl programmer so I may have made a
| fundamental mistake in my perl script.
| 
| begin .procmailrc
| 
| SHELL=/bin/sh
| 
| :0fbw
|| sed 's/usazdolmon0//'
| 
| :0 B:
| * ()\/ usaz[^ ]+
| { SERVER=$MATCH }
| 
| :0
| * ^From:.*\/[^        ].*
| { FROM=$MATCH }
| 
| :0
|| /home/netsaint/perlscript "$SERVER" "$FROM"
| 
| end .procmailrc
| 
| begin perl script
| #!/usr/bin/perl -w
| 
| %techs = qw(
|       3232006599(_at_)pagenetmessage(_dot_)net        BlakeBarnette
|       3232013648(_at_)pagenetmessage(_dot_)net        JasonAmbrose
|       3232013566(_at_)pagenetmessage(_dot_)net        JoelDudley
|       3232003415(_at_)pagenetmessage(_dot_)net        HunterBennett
|       3232013866(_at_)pagenetmessage(_dot_)net        ShaneReutzel
|       3232013565(_at_)pagenetmessage(_dot_)net        TonyHamrick
| );
| 
| $TIME = time;
| $TECH = $techs{$FROM};

$TECH = $techs{$ARGV[1]};

or 

$TECH = $techs{$ENV{FROM}};

| open(COMMAND,">/usr/local/netsaint/var/rw/netsaint.cmd") || die
| "Can't create file";
|       print COMMAND "[$TIME]
| ADD_HOST_COMMENT;$SERVER;0;$TECH;ACKNOWLEDGEMENT: $TECH has

ADD_HOST_COMMENT;$ARGV[0];...

or 

ADD_HOST_COMMENT;$ENV{SERVER};...

| acknowledged this problem";
| close(COMMAND);
|       open(COMMAND,">>/usr/local/netsaint/var/rw/netsaint.cmd") || die
| "Can't create file";
|       print COMMAND "[$TIME] ACKNOWLEDGE_HOST_PROBLEM;$SERVER;$TECH has
| acknowledged this problem";
| close(COMMAND);
| 
| end perl script
| 
| thanks for looking at my script!!
| 

I believe Philip already explained this a day or two ago. Arguments
passed on the command line are available to your perl script in @ARGV.
They are also exported to the environment by procmail, so are available
additionally from %ENV. But they are certainly not available magically
the way you are expecting.

Since this is about perl rather than procmail, this isn't really the
place to debug the perl script. But one thing especially jumps out at
me. Is there something you're not showing us that insures the $FROM
value set by procmail will always be one of the keys to %techs?



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>