I try send a mail with mail command, with the output of other command in the subject
subj="hello from $(hostname -s) $(date)"
echo "data" | mail -s $subj mail@mail
but I only get the first part of subject (hello from).
why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to quote your subject, like this:
If you don’t quote it, the
mailprogram will not know where your subject ends and will take the first “word” (hello) as the subject and everything else as an address.In general, it is good practice to always quote your variables.