Skip to content

Instantly share code, notes, and snippets.

@carlos22
Last active August 29, 2015 14:17
Show Gist options
  • Save carlos22/17141cea0d5a6f71be48 to your computer and use it in GitHub Desktop.
Save carlos22/17141cea0d5a6f71be48 to your computer and use it in GitHub Desktop.
carddav2vcf
#!/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;
@carlos22
Copy link
Author

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