Embedded Shell from Perl Script.
Hi experts
I have a shell routine to send mails from unix system..I would like to reuse it, passing perl variables to to the routine. However I am getting some errors
I can't get the value of the variables into the shell routine...
Here I have posted two routines.
1. It is working:
#sending.pl
$shell_in = <<'IN';
file_1=file1
file_2=file2
file_3=file3
SUBJ="Send mail from Unix with file attachments"
TO=name@domain.com
CC=name2@domain.com,name3@domain.com
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
IT WORKS
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix sendmail utility.
!
uuencode ${file_1} ${file_1}
uuencode ${file_2} ${file_2}
uuencode ${file_3} ${file_3}
!
) | sendmail -v ${TO} ${CC}
IN
$shell_out = `$shell_in`;
2. Passing some arguments from perl: I have the variables $file_1,$file_2,$file_3,$email_subject
$email_to_addrs, email_cc_addrs. If I print the variables in the routine I can see the values..The problem
is that I can not capture this variables..
sub send_mail {
$shell_in = <<'IN';
file_1=${$file1}
file_2=${$file2}
file_3=${$file3}
SUBJ=${$email_subject}
TO=${$email_to_addrs}
CC=${$email_cc_addrs}
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
IT DOES NOT WORK
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix sendmail utility.
!
uuencode ${file_1} ${file_1}
uuencode ${file_2} ${file_2}
uuencode ${file_3} ${file_3}
!
) | sendmail -v ${TO} ${CC}
IN
$shell_out = `$shell_in`;
}
Any help will be very appreciated.
I have other routines for sending mail from unix system that works very well, but I want to use it for learning purposes.
Thanks in advance!
Hi experts
I have a shell routine to send mails from unix system..I would like to reuse it, passing perl variables to to the routine. However I am getting some errors
I can't get the value of the variables into the shell routine...
Here I have posted two routines.
1. It is working:
#sending.pl
$shell_in = <<'IN';
file_1=file1
file_2=file2
file_3=file3
SUBJ="Send mail from Unix with file attachments"
TO=name@domain.com
CC=name2@domain.com,name3@domain.com
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
IT WORKS
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix sendmail utility.
!
uuencode ${file_1} ${file_1}
uuencode ${file_2} ${file_2}
uuencode ${file_3} ${file_3}
!
) | sendmail -v ${TO} ${CC}
IN
$shell_out = `$shell_in`;
2. Passing some arguments from perl: I have the variables $file_1,$file_2,$file_3,$email_subject
$email_to_addrs, email_cc_addrs. If I print the variables in the routine I can see the values..The problem
is that I can not capture this variables..
sub send_mail {
$shell_in = <<'IN';
file_1=${$file1}
file_2=${$file2}
file_3=${$file3}
SUBJ=${$email_subject}
TO=${$email_to_addrs}
CC=${$email_cc_addrs}
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
IT DOES NOT WORK
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix sendmail utility.
!
uuencode ${file_1} ${file_1}
uuencode ${file_2} ${file_2}
uuencode ${file_3} ${file_3}
!
) | sendmail -v ${TO} ${CC}
IN
$shell_out = `$shell_in`;
}
Any help will be very appreciated.
I have other routines for sending mail from unix system that works very well, but I want to use it for learning purposes.
Thanks in advance!