Thread Mail verarbeiten - Procmail -> Perl-Programm -> PHP-Programm (18 answers)
Opened by Erik at 2013-09-18 14:56

GwenDragon
 2013-09-24 12:03
#170554 #170554
User since
2005-01-17
14534 Artikel
Admin1
[Homepage]
user image
pipe.pl muss halt auch ein Pipe zur Ausgabe öffnen, die in der PHP eingelesen wird.

Schnippsel:
Code (perl): (dl )
1
2
3
4
5
6
7
open (my $pipe, '| /usr/bin/php /var/www/vhost/www.domain.de/script.php') 
  or die "Pipe kann nicht erstellt werden $!";
while (<STDIN>) { # Daten aus procmail über STDIN lesen
  print $pipe $_; # ausgeben an PHP
}
close $pipe
  or die "Pipe kann nicht geschlossen werden $!"; # Pipe hat ein problem



PHP-Schnippsel:
Code: (dl )
1
2
3
<?php 
$input = file_get_contents('php://stdin');
?>

http://php.net/manual/de/wrappers.php.php
http://php.net/manual/en/features.commandline.io-s...

Musst du selber testen, ob PHP das zulässt.

//EDIT: Upps, ich bin nicht sicher, ob so an PHP gepipet werden kann, denn PHP hat ja keinen Shebang.
Deswegen muss wohl die pipe noch ein php drin haben.

//EDIT2: geht jedenfalls per Shell
root@pc1 ~ # cat x.pl
#!/usr/bin/perl

open (my $pipe, '| /usr/bin/php /root/x.php')
or die "Pipe kann nicht erstellt werden $!";
while (<STDIN>) { # Daten aus procmail über STDIN lesen
print $pipe $_; # ausgeben an PHP
}
close $pipe
or die "Pipe kann nicht geschlossen werden $!"; # Pipe hat ein problem

root@pc1 ~ # cat x.php
<?php echo "------------PHP --------------";
echo file_get_contents('php://stdin');
echo "----------------------------" ?>
root@pc1 ~ # echo 123 | ./x.pl
------------PHP --------------123
----------------------------
root@pc1 ~ #

Last edited: 2013-09-24 12:33:36 +0200 (CEST)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Mail verarbeiten - Procmail -> Perl-Programm -> PHP-Programm