jakol Posted March 12, 2021 Share Posted March 12, 2021 Bonjour, Je souhaiterais savoir comment afficher le contenu d'un fichier .txt dans le corps d'un mail envoyé à partir d'un serveur unix. J'ai fait les commandes suivantes. Je peux envoyer le mail avec le fichier en pj. ./init/appli status >statutappli.txt && cat statutappli.txt | mail -s "Statutappli" jakol@unix.fr Merci pour votre retour jakol Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 12, 2021 Share Posted March 12, 2021 Résultat du moteur de recherche, la fin de la 1ère partie semble correspondre à ce que tu souhaites avoir https://www.tecmint.com/send-email-attachment-from-linux-commandline/ Quote Link to comment Share on other sites More sharing options...
jakol Posted March 12, 2021 Author Share Posted March 12, 2021 Merci pour ton retour j'ai lancé la commande suivante. Il y a pièce mais pas le contenu du fichier dans le corps du mail. Il y a un truc que je n'ai pas compris... mail -s "Statutappli" jakol@unix.fr < statutaplpi.txt Si tu as une idée...? Merci Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 12, 2021 Share Posted March 12, 2021 J'ai modifié ton dernier poste pour masquer l'adresse 😉 Peux-tu tester comme ceci (le -t manquait dans ton dernier post) : mail -s "Statutappli" -t jakol@unix.fr < statutaplpi.txt Quote Link to comment Share on other sites More sharing options...
jakol Posted March 12, 2021 Author Share Posted March 12, 2021 Merci No recipients specified Cela génère une "dead letter"... Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 12, 2021 Share Posted March 12, 2021 https://www.binarytides.com/linux-mail-command-examples/ Dans cette version, pas besoin du -t ... Et la partie "Take message from a file" correspond à tes tests... Quote Link to comment Share on other sites More sharing options...
jakol Posted March 12, 2021 Author Share Posted March 12, 2021 Merci pour ton retour mais rien dans le corps du mail.... Quote Link to comment Share on other sites More sharing options...
brice.wernet Posted March 12, 2021 Share Posted March 12, 2021 Il y a 5 heures, jakol a écrit : mail -s "Statutappli" jakol@unix.fr < statutaplpi.txt Si tu as une idée...? Merci Là il semble y avoir une coquille dans le nom du fichier. Vérifier le nom du fichier. qu’il soit accessible et qu’il ne soit pas vide. Tester en ligne de commande en mode verbeux: mail -v -s "StatutAppli" toto@pluton.com < fichier.txt Deuxième problème: quel client mail utilises-tu pour vérifier le résultat? Quote Link to comment Share on other sites More sharing options...
jakol Posted March 12, 2021 Author Share Posted March 12, 2021 le fichier n'est pas vide. Il est accessible ( 777). mail -v -s "StatutAppli" toto@pluto.com < statutappli.txt Mail Delivery Status Report will be mailed to <nomdelappli>. pour le client: thunderbird en IMAP Quote Link to comment Share on other sites More sharing options...
brice.wernet Posted March 12, 2021 Share Posted March 12, 2021 Il y a 16 minutes, jakol a écrit : pour le client: thunderbird en IMAP Pour résumer, tu reçois un mail, mais apparemment vide. Tu as checké la source du mail sous thunderbird? C'est quoi comme unix? Le fichier ne contient pas de caractère particulier? As-tu essayé la commande echo 'test mail' | mail -v -s 'statut' toto@pluton.com Citer Quote Link to comment Share on other sites More sharing options...
jakol Posted March 12, 2021 Author Share Posted March 12, 2021 J'ai des caractères illisibles pour la commande mail -v -s "StatutAppli" toto@pluton.com < fichier.txt U3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29sbGFib3JhdGlmcykgc3VyIGNv bGxhYi1hcHAxLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtbMTszMm1Ew6ltYXJyw6llG1sw OzM5bSAocGlkIDogMjUwOCkKU3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29s bGFib3JhdGlmcykgc3VyIGNvbGxhYi1hcHAyLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtb MTszMm1Ew6ltYXJyw6llG1swOzM5bSAocGlkIDogMTc0MikK c'est un serveur redhat echo 'test mail' | mail -v -s 'statut' toto@pluton.com résultat ok dans le mail : test mail U3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29sbGFib3JhdGlmcykgc3VyIGNv bGxhYi1hcHAxLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtbMTszMm1Ew6ltYXJyw6llG1sw OzM5bSAocGlkIDogMjUwOCkKU3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29s bGFib3JhdGlmcykgc3VyIGNvbGxhYi1hcHAyLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtb MTszMm1Ew6ltYXJyw6llG1swOzM5bSAocGlkIDogMTc0MikK sont dans le fichier source Quote Link to comment Share on other sites More sharing options...
brice.wernet Posted March 13, 2021 Share Posted March 13, 2021 Il y a 15 heures, jakol a écrit : J'ai des caractères illisibles pour la commande U3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29sbGFib3JhdGlmcykgc3VyIGNv bGxhYi1hcHAxLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtbMTszMm1Ew6ltYXJyw6llG1sw OzM5bSAocGlkIDogMjUwOCkKU3RhdHV0IGRlIGwnYXBwbGljYXRpb24gKEVzcGFjZXMgQ29s bGFib3JhdGlmcykgc3VyIGNvbGxhYi1hcHAyLmluLmFjLXN0cmFzYm91cmcuZnIgLi4uIBtb MTszMm1Ew6ltYXJyw6llG1swOzM5bSAocGlkIDogMTc0MikK Ca ressemble un un encodage base 64 (utilisé par les mails par défaut pour les fichiers binaires). Et si on revient au cat statutappli.txt | mail -s 'statut appli' 'toto@pluton.com' Ca marche? Et en créant un fichier "statutappli.txt" avec le teste 'hello world' dedans, ça marche? Parce que j'ai vraiment l'impression que ton fichier "statutappli' ne contient pas que du texte. Quote Link to comment Share on other sites More sharing options...
foetus Posted March 13, 2021 Share Posted March 13, 2021 (edited) effectivement, en utilisant 1 outil en ligne base64 on a ( sous Linux il y a 1 commande ou alors utiliser OpenSSL) Citer Statut de l'application (Espaces Collaboratifs) sur collab-app1.in.ac-strasbourg.fr ... [1;32mDémarrée[0;39m (pid : 2508) Statut de l'application (Espaces Collaboratifs) sur collab-app2.in.ac-strasbourg.fr ... [1;32mDémarrée[0;39m (pid : 1742) Edited March 13, 2021 by foetus Quote Link to comment Share on other sites More sharing options...
jakol Posted March 13, 2021 Author Share Posted March 13, 2021 Il y a 2 heures, brice.wernet a écrit : Ca ressemble un un encodage base 64 (utilisé par les mails par défaut pour les fichiers binaires). Et si on revient au cat statutappli.txt | mail -s 'statut appli' 'toto@pluton.com' Ca marche? Et en créant un fichier "statutappli.txt" avec le teste 'hello world' dedans, ça marche? Parce que j'ai vraiment l'impression que ton fichier "statutappli' ne contient pas que du texte. Oui ça marche quand tu intègres du texte. Quote Link to comment Share on other sites More sharing options...
brice.wernet Posted March 13, 2021 Share Posted March 13, 2021 Il y a 2 heures, foetus a écrit : effectivement, en utilisant 1 outil en ligne base64 on a ( sous Linux il y a 1 commande ou alors utiliser OpenSSL Le [1,32m me fait penser à du code de VT100. On peut avoir le fichier txt? Je soupçonne vraiment qu'il y a des caractères spéciaux dedans (genre eof) Quote Link to comment Share on other sites More sharing options...
jakol Posted March 14, 2021 Author Share Posted March 14, 2021 Le fichier txt contient les même données qui ont décodée en dessus... Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 Bonjour, sur chaque ligne il y a les caractères "^[". Je les ai virés manuellement et testé l'envoi. Le texte est bien affiché dans le corps du mail Comment supprimer ces caractère ? Merci Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 caractères Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 15, 2021 Share Posted March 15, 2021 Avec une commande comme sed ? Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 impossible de supprimer les caractères bleus ^] dans le fichier avec sed ou tr... Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 tty qui ne supporte pas le bash en couleur. Vous savez comment convertir ce fichier en txt simple? Merci pour votre retour. Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 15, 2021 Share Posted March 15, 2021 echo 'azerty^[qsdfgh' | sed 's/\^\[//g' Cela me donne: azertyqsdfgh Si cela te fait bien pareil, teste ceci : sed 's/\^\[//g' statutappli.txt | mail -s 'statut appli' 'toto@pluton.com' Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 Merci malheureusement "^[" les caractères bleus ne sont pas remplacé par l'espace y a t-il de supprimer les couleurs (le bleu),? Merci Quote Link to comment Share on other sites More sharing options...
ecatomb Posted March 15, 2021 Share Posted March 15, 2021 sed 's/\x1b//g' Ton caractère de couleur est 1b en hexadécimal. Il suffit de le supprimer via sed Sur mac, il faut faire comme ceci : sed $'s/\x1b//g' Avant le sed : Après : C'est cette série de caractères qui correspond à la couleur + le [1;32m 1b 5b 31 3b 33 32 6d Quote Link to comment Share on other sites More sharing options...
jakol Posted March 15, 2021 Author Share Posted March 15, 2021 Super. Ca marche! Merci beaucoup !! j'ai fait ça: sed 's/\x1b//g' statutCollab.txt | mail -s "Vérifications du Statut de Collab" toto@pluton.com j'ai ça comme résultat dans le mail Par contre, est-ce qu'on peut virer le "[1;32m" et "[0;39m" ? j'ai fait: sed 's/\x1b//g' statutCollab.txt && && sed 's/\[1;32m//g' statutCollab.txt | mail -s "Vérifications du Statut de Collab" toto@pluton.com sed 's/\x1b//g' statutCollab.txt | sed 's/\[1;32m//g' statutCollab.txt | mail -s "Vérifications du Statut de Collab" toto@pluton.com Mais cela fonctionne pas. Merci beaucoup. J'apprends grâce à toi ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.