Perl question: how to insert an e-mail address in a script
I'm using Fedora Core 3, and I'm modifying the LogWatch script below:
open(OUTFILE,"|$Config{'mailer'} $Config{'mailto'}") or die "Can't execute /bin/mail\n"; print OUTFILE "From: LogWatcher\n"; to something like: open(OUTFILE,"|$Config{'mailer'} $Config{'mailto'}") or die "Can't execute /bin/mail\n"; print OUTFILE "From: LogWatcher <operator@domain.com>\n"; What I'm trying to do is to receive an e-mail where the sender is shown only as "LogWatcher", instead of "LogWatcher@domain.com". And when you double click "LogWatcher", the e-mail operator@domain.com shows up. The problem is that I'm not a perl developer, and my modification is clearly incorrect. It returns the error: Possible unintended interpolation of @domain in string at /etc/cron.daily/00-logwatch line 681 Does anyone know how to do it? Thanks. |
The @ is a special character in Perl Z(designates an array variable). You should escape it by typing \@ instead of @ or just enclose your string in single quotes instead of double (which prevents Perl from trying to interpret variables).
|
Easiest way is to put the whole string in single-quotes so no interpolation is done.
|
Hi btmiller and eddiebaby1023,
The \@ worked like a charm! Thanks a lot. |
All times are GMT -5. The time now is 02:14 AM. |