[prev in list] [next in list] [prev in thread] [next in thread] 

List:       procmail
Subject:    Re: FW: UPDATED: passing variables to a perl script
From:       D E Hammond <procmail1 () tradersdata ! com>
Date:       2000-11-27 19:35:32
[Download RAW message or body]

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@pagenetmessage.net	BlakeBarnette
| 	3232013648@pagenetmessage.net	JasonAmbrose
| 	3232013566@pagenetmessage.net	JoelDudley
| 	3232003415@pagenetmessage.net	HunterBennett
| 	3232013866@pagenetmessage.net	ShaneReutzel
| 	3232013565@pagenetmessage.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@lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic