X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/f081a28c79966703940a8e7de563b8622f08e2a5..590d3718adc3886c5f5e72a684b3e7b121da994f:/bin/office365-book?ds=sidebyside diff --git a/bin/office365-book b/bin/office365-book new file mode 100755 index 0000000..3054a5c --- /dev/null +++ b/bin/office365-book @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +user=samir.benmendil@ultrahaptics.com +pass=$(pass ultrahaptics/okta.com/samir.benmendil@ultrahaptics.com) +url="https://outlook.office365.com/EWS/Exchange.asmx" + +read -r -d '' data < + + + + $1 + + + +EOF + +out=$(curl -s -u "$user:$pass" -L "$url" -d "$data") + +readarray -t email < <(echo $out | xpath -q -e '//t:Mailbox/t:EmailAddress/text()') +readarray -t name < <(echo $out | xpath -q -e '//t:Contact/t:DisplayName/text()') + +count=${#email[@]} + +if [[ "$count" -eq 0 ]]; then + echo "No matches" + exit 1 +fi + +echo "$count matches" +for (( i = 0; i < $count; i++ )); do + echo -e "${email[$i]}\t${name[$i]}\t" +done