LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   send an email of script output (https://www.linuxquestions.org/questions/suse-opensuse-60/send-an-email-of-script-output-742296/)

s_linux 07-24-2009 10:57 AM

I'm trying to attach file. But no luck...I tried your command...
uuencode /home/uname/Result Result.txt | mail -s "Health Check Status" uname@company.com

I got email with all junk like below..

begin 644 result.txt
M1$56(&5$:7)E8W1O<GD@5')E92!3=&%T=7,@:7,@3TL@;VX@>$1E=E1S=%5A
M=$EN=')A,@I-96UO<GD@4W1A='5S(&]N('A$9794<W15871);G1R83(Z($UE
M;3H@,S@V-S0T-&L@=&]T86PL(#$P,S`R,3)K('5S960L(#(X,S<R,S)K(&9R
M964L(#DP,C,V:R!B=69F97)S(2$*0U!5(%-T871U<R!O;B!X1&5V5'-T56%T

I also tried unix2dos, but it says command not found. just to let you know that Im using outlook 2007.

@s_linux
Can you send a copy to yourself on the Linux system and see what it looks like there? It would help to know when the mangling happens -- on the Linux system or later. The mail -c option followed by your username (without any @domain_name) should do it.
What are you using to send the mail from your Linux system to wherever? postfix, sendmail ... ?

-c option doent seems to be working. what you mean postfx, sendmail? Im just using mail command. Thanks

catkin 07-24-2009 11:48 AM

Quote:

Originally Posted by s_linux (Post 3619028)
-c option doent seems to be working. what you mean postfx, sendmail? Im just using mail command. Thanks

Works for me:
Code:

c@CW8:~$ echo 'jhfgjh
fdsf
asdf' | mail -c c -s test root

That sent a copy to user c as well as to user root. I didn't get to see it on the local system because it's set up to forward all mail to my mail ISP and comes in to Outlook.

The mail command only generates local mail. How is it getting to your Outlook? I'm guessing that you have some ISP providing SMTP and POP3 mail servers. For the mail generated by the mail command to get to your ISP you need to transfer it, probably by SMTP, from your local system to your ISP (or Outlook could be collecting it directly from your local system). The commonest packages for doing SMTP are postfix and sendmail.

What does the output from
Code:

mail -wxyz
look like? Mine looks like
Code:

c@CW8:~$ mail -wxyz
mail: invalid option -- w
usage: mail [-eIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-s subject] to-addr ...
            [-- sendmail-options ...]
      mail [-eIiNnv] -f [name]
      mail [-eIiNnv] [-u user]

This shows the -c option.

I'm beginning to wonder what your mail command is. What is the output from
Code:

type mail
/bin/ls -l /usr/bin/Mail /usr/bin/mail /usr/bin/mailx

Mine looks like
Code:

c@CW8:~$ type mail
mail is hashed (/usr/bin/mail)
c@CW8:~$ /bin/ls -l /usr/bin/Mail /usr/bin/mail /usr/bin/mailx
-rwxr-xr-x 1 root root 80316 2007-10-24 14:50 /usr/bin/mail
lrwxrwxrwx 1 root root    4 2009-06-24 23:07 /usr/bin/Mail -> mail
lrwxrwxrwx 1 root root    4 2009-06-24 23:07 /usr/bin/mailx -> mail


s_linux 07-24-2009 12:25 PM

This time i tried with c (I didn't read all your post by this time)option, i see some Undelivered Mail return to Sender. but message looks good. Then I tried following..
# echo 'testtesttest' | mail -c root
Send options without primary recipient specified.
Usage: mail [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
[-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr ...
mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]
mail [-BDeinNRv~] [-A account] [-u user]

# echo 'testtesttest' | mail -c -s test root
hostname:/usr/local/bin # send-mail: invalid option -- s
send-mail: fatal: usage: send-mail [options]

Here is output of the commands which you gave me...
# mail -wxyz
mail: illegal option -- w
Usage: mail [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
[-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr ...
mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]
mail [-BDeinNRv~] [-A account] [-u user]


# type mail
mail is hashed (/usr/bin/mail)


/bin/ls -l /usr/bin/Mail /usr/bin/mail /usr/bin/mailx
lrwxrwxrwx 1 root root 4 Nov 13 2008 /usr/bin/Mail -> nail
lrwxrwxrwx 1 root root 4 Nov 13 2008 /usr/bin/mail -> nail
lrwxrwxrwx 1 root root 4 Nov 13 2008 /usr/bin/mailx -> nail

Thanks.

rn_ 07-24-2009 02:23 PM

Quote:

Originally Posted by s_linux (Post 3619028)
I also tried unix2dos, but it says command not found.

you will need the unix2dos package installed for this.


Quote:

Originally Posted by s_linux (Post 3619028)
just to let you know that Im using outlook 2007.

I am using outlook 2007 as well, and uuencode works for me! hmmm.. it appears as if something "ate" off the 'end'. There's supposed to be an 'end' keyword at the end of the uuencoded block. If I manually remove the 'end' and mail the file i get the same result as you. I'm not sure what could be doing that.

just in case something is chomping of the last line, try this:

Code:

{ uuencode /home/uname/Result Result.txt ; echo ; echo ; } | mail -s "Health Check Status" uname@company.com
!! KEEP THE SPACES before and after the { } !!

catkin 07-25-2009 03:47 AM

Quote:

Originally Posted by s_linux (Post 3619127)
This time i tried with c (I didn't read all your post by this time)option, i see some Undelivered Mail return to Sender. but message looks good. Then I tried following..
# echo 'testtesttest' | mail -c root
Send options without primary recipient specified.

You didn't specify the primary recipient, only the copy recipient. Let's keep close to the original problem (smart idea when doing tests) and add the copy recipient:
Code:

mail -c root -s "Health Check Status" uname@company.com < /home/uname/Result
Quote:

Originally Posted by s_linux (Post 3619127)
Code:

# echo 'testtesttest' | mail -c -s test root
hostname:/usr/local/bin # send-mail: invalid option -- s


That's because you didn't put the name of the copy recipient after the -c option.

Quote:

Originally Posted by s_linux (Post 3619127)
Here is output of the commands which you gave me...
Code:

# mail -wxyz
mail: illegal option -- w
Usage: mail [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
            [-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr ...
      mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]
      mail [-BDeinNRv~] [-A account] [-u user]


That's very different to what I got suggesting your "mail" program is not the same as mine.

Quote:

Originally Posted by s_linux (Post 3619127)
Code:

# type mail
mail is hashed (/usr/bin/mail)
/bin/ls -l /usr/bin/Mail /usr/bin/mail /usr/bin/mailx
lrwxrwxrwx 1 root root 4 Nov 13  2008 /usr/bin/Mail -> nail
lrwxrwxrwx 1 root root 4 Nov 13  2008 /usr/bin/mail -> nail
lrwxrwxrwx 1 root root 4 Nov 13  2008 /usr/bin/mailx -> nail


Ah ha! When you run the mail command it actually runs /usr/bin/nail which is an alternative package I have never used.

You could
  1. Read the nail documentation ...
  2. Check for any unusual configuration (what you are trying to do is straightforward and would probably work "out of the box")
  3. Do the test of sending a copy to a local user so you can see if the mangling happened when you composed the mail or when it was transmitted.
  4. Figure out how you mail is getting from the command line to Outlook, especially how it gets off your local system. The mangling could be happening there.
  5. Ask a new LQ question mentioning "nail (mailx alternative)" in the subject.
Best

Charles


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