If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > SendMail embedding linefeeds in the message body

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-02, 13:44
Flournoy Flournoy is offline
Registered User
 
Join Date: Nov 2002
Posts: 4
Angry SendMail embedding linefeeds in the message body

OK, first, I haven't even begun unix 101 or shell scripts so go easy with me. This is what we're using and it works, I'd just like to dress up the body by inserting newline/return/LFCR, tabs, etc .... Is it possible?

java SendMail -g est04grp -f pcunix -s "EST04 Notification" -m "Attached please find two reports: est04.fc.new which contains a list of original Final Certificates printed and est04.fc.rep which contains a list of reprinted Final Certificates. Please contact Jeff Miller, if there are any questions or concerns. Thank you." -a "$NEW_FC_REPORT" -a "$REPRINTED_FC_REPORT"
Reply With Quote
  #2 (permalink)  
Old 11-19-02, 04:46
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
You should be able to use escape sequences with the backslash character...

The example below is all on one line.

echo "Here is a newline...\n\t...and this line begins with a tab\nand here is \"some text\" in enclosed quotes."

Here is a newline...
...and this line begins with a tab
and here is "some text" in enclosed quotes.
Reply With Quote
  #3 (permalink)  
Old 11-19-02, 12:30
WingMan WingMan is offline
Registered User
 
Join Date: Aug 2002
Location: UK
Posts: 87
go Damian
Reply With Quote
  #4 (permalink)  
Old 11-19-02, 12:37
Flournoy Flournoy is offline
Registered User
 
Join Date: Nov 2002
Posts: 4
Unhappy flournoy

It didn't work, the email is recieved with the slashes and characters printed with the text. I've tried separating the message with quotes and putting the control characters between the lines and it still prints the control characters within the body. HELP !
Reply With Quote
  #5 (permalink)  
Old 11-26-02, 11:02
WingMan WingMan is offline
Registered User
 
Join Date: Aug 2002
Location: UK
Posts: 87
Humm .... Have you tried putting the text into a script variable, and then using the script variable in the mail statement ??
Reply With Quote
  #6 (permalink)  
Old 11-26-02, 12:14
Flournoy Flournoy is offline
Registered User
 
Join Date: Nov 2002
Posts: 4
Wink

Yes, I have, it printed the control characters in the body.

MY_MESSAGE="HELLO....\n\t...did it work"

java SendMail -g est04grp -f pcunix -s "My Test" -m $MY_MESSAGE

And it printed in the body of the e-mail:

HELLO....\n\t...did it work


I don't know what the problem is .....
Reply With Quote
  #7 (permalink)  
Old 11-27-02, 12:14
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
I'm not sure what could be going on here. I've posted a thread on comp.unix.shell which might throw some light on the subject.

http://dbforums.com/t579094.html
Reply With Quote
  #8 (permalink)  
Old 11-27-02, 15:11
backer backer is offline
Registered User
 
Join Date: Nov 2002
Posts: 7
Quote:
Originally posted by Flournoy
Yes, I have, it printed the control characters in the body.

MY_MESSAGE="HELLO....\n\t...did it work"

java SendMail -g est04grp -f pcunix -s "My Test" -m $MY_MESSAGE

And it printed in the body of the e-mail:

HELLO....\n\t...did it work


I don't know what the problem is .....

How about not putting your \'s in quotes... end quotes before the slash?
Reply With Quote
  #9 (permalink)  
Old 11-27-02, 15:13
backer backer is offline
Registered User
 
Join Date: Nov 2002
Posts: 7
Quote:
Originally posted by backer
How about not putting your \'s in quotes... end quotes before the slash?
That almost appeared how I wanted it ..

I was trying to say, \\'s maybe?
Reply With Quote
  #10 (permalink)  
Old 11-27-02, 15:47
Flournoy Flournoy is offline
Registered User
 
Join Date: Nov 2002
Posts: 4
I've tried that,
MY_MESSAGE="HELLO...."\n\t"...did it work"
prints
HELLO....\n\t...did it work
go figure ....

With spaces
MY_MESSAGE="HELLO...." \n\t "...did it work"
prints
HELLO....

This looks way to easy to be so hard ......
Reply With Quote
  #11 (permalink)  
Old 11-28-02, 10:30
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
I've tried this and it seems to work okay...

public class JavaTest {
public static void main (String[] args) {
System.out.println(args[0]);
}
}

java JavaTest "Text
on
many
lines."

The output looks like this:

Text
on
many
lines.

If passing in your message body parameter over multiple lines doesn't work, I would suggest that the SendMail application is stripping out the newlines.
Reply With Quote
  #12 (permalink)  
Old 12-15-02, 16:56
jmcphe jmcphe is offline
Registered User
 
Join Date: Dec 2002
Posts: 4
good old meta characters. instead of double quotes " use single quotes '
if that doesn't work you may need to escape your backslashes \ with a backslash \ themselves.

Check this. To ftp into an NT ftp server from a unix one, I had to do the following:
user domain\\\\name password

a the 4 backslashes send 2 backslashes to the script, which sends 1 backslash to the ftp program. I think you're running into the same thing. Your stuffs is being interpretted in the double quotes. single quotes will kill the issue if you're using a unix shell. escaping the backslash \ escape character with an escape character, namely a backslash, will send a literal backslash through. Of course, you may have to do what I did and escape the escape of the escape. Hehehe. any wonder why regular expressions look so funny?
Reply With Quote
  #13 (permalink)  
Old 12-15-02, 17:10
jmcphe jmcphe is offline
Registered User
 
Join Date: Dec 2002
Posts: 4
oops. I misread the thread. Please ignore my above lame comments. In atonement, I offer the following
$ var="foo\nbar"; export var
$ echo $var
foo
bar
$ var2=`echo $var`; export var2
$ echo $var2
foo bar
$ cat << !!
> $var2
> !!
foo
bar


Go figure, huh? Cat isn't interpretting the newlines into their ascii equivalents, but if you feed the already interpretted newlines into it, it works, but breaks the original. I'll leave it up to ya'll.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On