Hallo zusammen,
wie kann ich in EOF die Ausgaben von mehreren Loop-Iteration reinschreiben. Zwar funktioniert es mit der Variablenzuweisung aber diese wird offensichtlich bei jeder Iteration überschrieben.
Wahrscheinlich ist meine Herangehensweise hier falsch, aber ich wollte EOF beibehalten, weil somit die leidige Obfuskieren vermieden wird.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # !/bin/bash get_mimetype(){ # warning: assumes that the passed file exists file --mime-type "$1" | sed 's/.*: //' } to="meineEmail@gmail.com" from="meineEmail@gmail.com" boundary=$(uuidgen -t) body_boundary=$(uuidgen -t) now=$(date +"%a, %d %b %Y %T %z") declare -a attachments attachments=( "foo.txt" "bar.pdf" ) # now loop over the attachments, guess the type # and produce the corresponding part, encoded base64 for file in "${attachments[@]}"; do [ ! -f "$file" ] && echo "Warning: attachment $file not found, skipping" >&2 && continue mimetype=$(get_mimetype "$file") attachment=$(printf '%s\n' "--${boundary} Content-Type: $mimetype Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"$file\" " base64 "$file" ) echo done sendmail -t <<EOF2 From: ${from} To: ${to} Date: ${now} Subject: Meine Attachements MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="${boundary}" --${boundary} Content-Type: multipart/alternative; boundary="${body_boundary}" --${body_boundary} Content-type: text/plain; charset=utf-8 Hier ist der normale Text. --${body_boundary} Content-type: text/html; charset=utf-8 Content-Disposition: inline <!DOCTYPE html> <html> <body> HTML - Text </body> </html> $attachment --${body_boundary}-- --${boundary}-- EOF2 |
Danke für Tipps!
gruß napterk