SI-POER <[EMAIL PROTECTED]> wrote:
>
> Hebat juga ya si procmail...
> Mau nambahin pertanyaan nich..
>
> Bisa nggak headernya email dijadikan variable buat input ke program lain.
>
> misalnya subject: coba1, terus nantinya bakal jalanin program coba1, tapi
> subjectnya itu nantinya bakal berubah terus...
>
Berikut ini solusi yang saya dapat dari arsip 'best procmail list'.
Sepertinya harus ada yang dicustomize lagi, terutama pada baris:
system "cat $outfile | /usr/ucb/Mail -s $header $retpath ";
kayaknya bukan path standard Linux.
Saya sendiri belum coba, kalo ada problem (terutama perl script-nya) saya
tidak bisa bantu. kawan-kawan 'perl hacker' mungkin lebih tahu.
--
ernasm.
--------------------------------------------------------------------------
Subject: Re: Program execution via procmail
To: Roger Squire <[EMAIL PROTECTED]>
Date: Wed, 11 Aug 1993 09:31:03 -0400 (EDT)
Cc: Procmail Mailing List <[EMAIL PROTECTED]>
>> I have set up a user on our network called - server, what I need to do is to
>> send a mail message to the user <server>, with the following in the message
>> body
>>
>> PROGRAM : <program name> <paramter1> <paramter2>
Here's my solution to this. In .procmailrc, I have
:0: # execute
* ^subject: execute$
| $MAILDIR/bin/execute.pl
which pipes the message to a perl script called execute.pl.
Execute.pl looks like
#!/usr/local/bin/perl
$outfile="/tmp/execute.out.$$";
$tmpinp="/tmp/execute.inp.$$";
open(SAVEINP,">$tmpinp") || die "Can't open $tmpinp" ;
print SAVEINP <<'DONE';
PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
set -x
DONE
header: while (<>) {
chop;
# Find the return-path. Probably should look at From line if no
# return-path, but I haven't done it yet.
if (/^Return-Path:.*\<(.*)\>.*$/) {
$retpath=$1;
next header;
}
if ($_ eq "") {last header};
}
main: while (<>) {
# look for password: entry
if ((!defined($password)) && (/^(pass.*:\s*)(\S*)(.*)/i)) {
$password=$2;
$passecho=$1.'*' x length($2).$3."\n";
next main;
}
# assume -- means beginning of .sig - ignore everything after it
if (substr($_, 0, 2) eq '--') {
last main;
}
# otherwise send to script SAVEINP
print SAVEINP $_ ;
}
close(SAVEINP);
if ($password eq "mypass") {
open(SAVEOUT,">&STDOUT");
open(SAVEERR,">&STDERR");
open(STDOUT,">$outfile") || die "Can't redirect stdout";
open(STDERR,">&STDOUT") || die "Can't redirect stdout";
select(STDERR); $| = 1;
select(STDOUT); $| = 1;
print STDOUT $passecho;
system "sh $tmpinp";
close(STDOUT);
close(STDERR);
open(STDOUT,">&SAVEOUT");
open(STDERR,">&SAVEERR");
} else {
open(SAVEOUT,">$outfile");
if ((defined($password)) && (length($password) gt 0)) {
print SAVEOUT "bad password - cannot execute command\n";
} else {
print SAVEOUT "no password given - cannot execute command\n";
}
close(SAVEOUT);
}
chop($date=`date`);
$header="\"execute output from $date\"";
system "cat $outfile | /usr/ucb/Mail -s $header $retpath ";
unlink $tmpinp;
unlink $outfile;
Basically, you send a message with the subject "execute", and the body
of the message has shell commands. You also need to have the line
"password: mypass" in order for this to work (you should change mypass
to something more secure).
Hope this helps,
Dave
--
David M. Meyer Mechanical & Aerospace Engineering
[EMAIL PROTECTED] University of Virginia
NeXTmail ok
______________________________________________________________________
Utk berhenti langganan kirim email ke [EMAIL PROTECTED]
Sudah cari di arsip? http://www.linux.or.id/milis.php3#arsip-id-linux
Utk info etika diskusi, kirim email kosong ke [EMAIL PROTECTED]