Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Angry Unanswered: 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"

  2. #2
    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.

  3. #3
    Join Date
    Aug 2002
    Location
    UK
    Posts
    87
    go Damian

  4. #4
    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 !

  5. #5
    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 ??

  6. #6
    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 .....

  7. #7
    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

  8. #8
    Join Date
    Nov 2002
    Posts
    7
    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?

  9. #9
    Join Date
    Nov 2002
    Posts
    7
    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?

  10. #10
    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 ......

  11. #11
    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.

  12. #12
    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?

  13. #13
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •