Hallo zusammen,
ich möchte in einem Perl Script das die Mail Adresse via ldap ausliest einen Bash Befehl ausführen.
Das Script dieht wie folgt aus.
Code:
#!/usr/bin/perl
# Parameter: Username, PDF File
use MIME::Entity;
### get the ARGS
$to = 'ldapsearch -LLL cn= $ARGV[0] mail -h 192.168.0.1 -x | grep mail | cut -d" " -f2-';
$pdffile = $ARGV[1];
### set some vars
$mailpipe = '| /usr/lib/sendmail -t -oi';
$from = "root";
$subject ="PDF File";
$inhalt = "Your PDF print";
# create the mail
my $mail = MIME::Entity->build( Type => 'text/plain',
From => $from,
To => $to,
Subject => $subject,
Data => $inhalt
);
# attach the pdf file
$mail->attach( Path => $pdffile,
Type => 'application/pdf',
Encoding => 'base64'
);
# open mailpipe and send the mail
open MAIL, "$mailpipe" or die "Could not open mailpipe \"$mailpipe\" !\n";
$mail->print(\*MAIL);
close MAIL;
Es soll halt
Code:
ldapsearch -LLL cn= $ARGV[0] mail -h 192.168.0.1 -x | grep mail | cut -d" " -f2-
ausgeführt werden.
In der Varibale $ARGV[0] steht der Benutzername drin.
Wie kann ich diesesen Befehl im Script ausführen?
Danke schon einmal.
MfG
Dominic
Lesezeichen