LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2005, 10:26 AM   #1
Pastorino
Member
 
Registered: Jul 2004
Distribution: RHEL 6.2
Posts: 35

Rep: Reputation: 17
Question 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.
 
Old 08-06-2005, 11:42 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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).
 
Old 08-07-2005, 04:36 AM   #3
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Easiest way is to put the whole string in single-quotes so no interpolation is done.
 
Old 08-08-2005, 08:28 AM   #4
Pastorino
Member
 
Registered: Jul 2004
Distribution: RHEL 6.2
Posts: 35

Original Poster
Rep: Reputation: 17
Hi btmiller and eddiebaby1023,

The \@ worked like a charm! Thanks a lot.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shel script mail send ("/" in mail address) problem anaid Linux - Networking 3 08-23-2005 07:41 AM
perl script to report new mail nibbler Programming 1 07-02-2005 09:13 AM
Exim - piping mail sent to a particular address to a script Khang Linux - Software 2 01-31-2005 11:04 AM
Shell script for insert ip address into an ordered list of IPs inTrouble? Linux - Newbie 2 10-27-2003 02:21 AM
perl script to insert image information rhuser Programming 1 03-12-2003 05:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration