Last active
August 29, 2015 14:17
-
-
Save carlos22/17141cea0d5a6f71be48 to your computer and use it in GitHub Desktop.
carddav2vcf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# args | |
if [ "$#" -eq 0 ];then | |
echo "$0 <url> <user> <file.vcf>"; | |
exit 3; | |
fi | |
DAVURL="$1"; | |
DAVUSER="$2"; | |
VCF="$3"; | |
echo -n "Password: " | |
read -s DAVPW; | |
echo ""; | |
echo "Start"; | |
# truncate file | |
echo -n > $VCF; | |
# get remote file listing | |
for i in `davix-ls --userlogin $DAVUSER --userpass $DAVPW $DAVURL`; do | |
echo "Downloading $i"; | |
# download files and append them to vcf | |
davix-get --userlogin $DAVUSER --userpass $DAVPW $DAVURL/$i >> $VCF | |
done | |
# remove empty lines | |
sed -i '/^$/d' $VCF | |
exit 0; |
wget https://gist.github.com/carlos22/17141cea0d5a6f71be48/raw/3e1028d9c46f319e7065bf651d7d21ab7d5516d9/carddav2vcf.sh
chmod +x carddav2vcf.sh
echo "mypw" > my_secret_pw_file
cat my_secret_pw_file | ./carddav2vcf.sh https://myhost.tld/carddav/username/user%40domain.tld [email protected] output.vcf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires davix, Install in Ubuntu with
sudo apt-get install davix