Place date command inside e-mail

Asked

Viewed 30 times

-1

I own a script, and would like it to send an email to users informing the time that the same was executed.

Example:

$script_deploy.sh
# Envio de e-mail aviso deploy
echo "=> Envio de e-mail para os usuarios sobre o inicio do deploy"
mail -s "DEPLOY" [email protected] < /opt/email-inicio-deploy.txt

$/opt/email-inicio-deploy.txt
echo "Informamos que o sistema tera um deploy as `date +%H:%M`"

Well, the email arrives with the following text:

Informamos que o sistema tera um deploy as `date +%H:%M`

How do I do for command date be interpreted? I’ve tried so many ways and I couldn’t.

  • You can indicate the shapes you’ve tried?

1 answer

1

Hello,

You can send the time message as follows:

mail -s "DEPLOY" [email protected] <<< "Informamos que o sistema tera um deploy as $(date +'%H:%M')"
  • Thanks for the answer, but by the shell line I can. What I need is for him to interpret from inside a file, I think it would be necessary to have a sub-shell -> Sending by the direct command line comes out like this: mail -s "DEPLOY" [email protected] <<< "We inform that the system will have a deploy as $(date +'%H:%M')" -> message received by the client We inform that the system will have a deploy at 14:59 -> sending via file, the message arrives as below: echo "We inform that the system will have a deploy at $(date +'%H:%M')"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.