LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-23-2010, 06:16 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
mail Subject getting truncated


Hi All,

I am facing a simple problem, but could not reconginse so far. Here is a script that I use to send mails

Code:
#!/bin/bash
SUBJECT="This server has problem"
TO="308718@CDCTGIMCLSB.localdomain"
cat mail | mail -s ${SUBJECT} ${TO}
I am receiving the mail in mail box of system, but subject line getting truncated to just This instead of This server has problem.

Here is mail

Code:
[308718@CDCTGIMCLSB ~]$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/308718": 2 messages 1 new 2 unread
 U  1 308718@CDCTGIMCLSB.l  Tue Sep 21 15:42  15/682   "hi vinay"
>N  2 308718@CDCTGIMCLSB.l  Thu Sep 23 15:41  20/841   "This"
& 2
Message 2:
From 308718@CDCTGIMCLSB.localdomain  Thu Sep 23 15:41:34 2010
Date: Thu, 23 Sep 2010 15:38:22 +0530
From: 308718@CDCTGIMCLSB.localdomain
To: 308718@CDCTGIMCLSB.localdomain, has@CDCTGIMCLSB.localdomain,
        problem@CDCTGIMCLSB.localdomain, server@CDCTGIMCLSB.localdomainSubject: This

#!/bin/bash
SUBJECT="This server has problem"
TO="308718@CDCTGIMCLSB.localdomain"
cat mail | mail -s ${SUBJECT} ${TO}

& q
Saved 1 message in mbox
Held 1 message in /var/spool/mail/308718
Subject line is getting split as shown below
Code:
To: 308718@CDCTGIMCLSB.localdomain, has@CDCTGIMCLSB.localdomain,
        problem@CDCTGIMCLSB.localdomain, server@CDCTGIMCLSB.localdomain
But following command directly in command prompt works well

Code:
cat mail | mail -s  "This server has problem" 308718@CDCTGIMCLSB.localdomain
Any Ideas ?

Last edited by vinaytp; 09-23-2010 at 08:16 AM.
 
Old 09-23-2010, 08:54 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,064
Blog Entries: 14

Rep: Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248
Your variable is losing the quotes. Alternatively try putting extra quoting when you set it:

Maybe putting quotes around ${SUBJECT} in the mail line.
cat mail | mail -s "${SUBJECT}" ${TO}

OR quoting the quotes in the set line:
SUBJECT='"This server has problem"'

OR escaping the quotes:
SUBJECT=\"This server has problem\"

Sometimes you have to try various things to insure the characters you want are passed properly.
 
Old 09-23-2010, 09:46 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thanks MensaWater, Your suggestion worked for me !!
 
Old 09-23-2010, 11:17 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,064
Blog Entries: 14

Rep: Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248Reputation: 1248
No problem.

If this is resolved please use the thread tools to mark it as resolved. Also please note exactly which of the things I suggested fixed it. That way if someone else is searching in future they'll find the fix.
 
Old 09-23-2010, 11:26 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Hi MensaWater,

Sorry, forgot to mark thread as solved.

Adding double quotes on ${SUBJECT} fixed it !!

Code:
cat mail | mail -s "${SUBJECT}" ${TO}
Thanks again.
 
  


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
Logging mail subject headers in Postfix timjames Linux - Software 1 03-20-2009 03:07 PM
delete all mail with exactly same subject from postfix queue badboynick21 Linux - Server 4 10-08-2008 06:12 AM
Rewriting mail subject with Formail Sheridan Linux - Server 3 02-29-2008 09:33 AM
message are getting truncated in the mail nileshrg Linux - General 6 07-13-2006 12:49 AM
How do I enter a subject when awk | data to mail 360 Programming 3 05-06-2002 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:55 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration