Skip to content

Instantly share code, notes, and snippets.

@madrzejewski
Created July 8, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madrzejewski/5787bde4579385b53b08724ce8d2ca16 to your computer and use it in GitHub Desktop.
Save madrzejewski/5787bde4579385b53b08724ce8d2ca16 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Example for : https://blog.madrzejewski.com/traiter-json-shell-cli
set -euo pipefail
LC_ALL=C
OLD_IFS=$IFS
IFS=$'\n'
cpapi2 --output=json --user=mondev Email listpops | jq -c '.cpanelresult.data[] | {email: .email}' | while read json ; do
email=$(echo $json | jq -r .email)
echo "Envoi à $email"
echo "Contenu de mon message" | mail -s "Sujet" $email
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment