(→envoyer un mail en html avec pièce jointe en passant par sendmail ( en KSH ):) |
|||
Ligne 1 : | Ligne 1 : | ||
+ | retour vers [[Unix - Linux]] | ||
+ | |||
=== Unix generique === | === Unix generique === | ||
-------------------- | -------------------- |
retour vers Unix - Linux
Sommaire |
avec le programme date de GNU (Linux, BSD, ...):
date +%Y:%m:%d -d "yesterday"
ou
date +%Y:%m:%d -d "1 day ago"
ou
date --date='-1 day'
Sans utiliser date:
En perl:
perl -e 'print scalar localtime( time - 86400 ) . "\n";'
avec nawk. (Testé sous solaris 8, 10 )
nawk 'BEGIN{printf "0t%d=Y\n", srand()-86400}' | adb
avec nawk et date:
/usr/bin/truss /usr/bin/date 2>&1 | nawk -F= '/^time\(\)/ {gsub(/ /,"",$2);printf "0t%d=Y\n", $2-86400}' | adb
mail d *
Mail_Dest = destinataires séparé par des virgules
Mail_Sujet = objet du mail
Pièce jointe = Txt
boundary="-q1w2e3r4t5" , la chaîne -q1w2e3r4t5 est arbitraire et pourrais etre remplacé par une autre chaîne singulière. Elle sert a dissocier les parties du mail: message et pièce jointe.
( echo 'To: '$Mail_Dest echo 'Subject: '$Mail_Sujet echo 'MIME-Version: 1.0' echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"' echo echo '---q1w2e3r4t5' echo 'Content-Type: text/html' echo 'Content-Disposition: inline' echo ' <HTML> <BODY style="font-family:Verdana;font-size:0.8em"> ' echo "Bonjour,<br> <br> ... Corps du messages ... <br> echo "<br> Cordialement<br> <a href="mailto:mail-signature@laposte.fr">intitulé signature</a><br> </BODY> </HTML>" echo '---q1w2e3r4t5' echo 'Content-Type: application/octet-stream"' echo "Content-Transfer-Encoding: quoted-printable" echo 'Content-Disposition: attachment; filename="'$(basename $Txt)'"' echo cat $Txt echo '---q1w2e3r4t5--' ) | /usr/lib/sendmail $Mail_Dest