Skip to content

Instantly share code, notes, and snippets.

@adujardin
Last active March 2, 2017 14:02
Show Gist options
  • Save adujardin/10e2e311b09e96733d4af682e5313ba7 to your computer and use it in GitHub Desktop.
Save adujardin/10e2e311b09e96733d4af682e5313ba7 to your computer and use it in GitHub Desktop.
Script to download a ZED calibration file
#!/usr/bin/env bash
usage() {
echo "This script needs the serial number as argument like this :"
echo "bash dl_zed_calib.sh 1010 [path/]"
exit 1
}
conf_path="/usr/local/zed/settings/"
# Check the input (serial number and the optional path, ending with '/')
if [ "$#" -eq 2 ] || [ "$#" -eq 1 ]; then
if [[ "$1" =~ ^[0-9]+$ ]]; then # serial is a number
if [ "$#" -eq 2 ]; then # custom path given
if [[ "$2" == */ ]]; then # path ends with a "/"
conf_path="${2}"
else
echo "Invalid path (must end with '/')"
fi
fi
echo "Calibration file will be saved in ${conf_path}"
else
echo "Invalid serial number"
usage
fi
else
echo "Invalid parameters"
usage
fi
serial_number="${1}"
conf_file="${conf_path}SN${serial_number}.conf"
echo "Trying to download SN${serial_number}.conf..."
# Unlikely `curl` options found by @nesnes
curl --silent -L "https://www.stereolabs.com/developers/calib/?SN=${serial_number}" -A "Mozilla/4.0" -o "${conf_file}" --compressed
# Check if the file is valid
if grep --silent "ERROR" "${conf_file}"
then
echo "The serial seems invalid"
rm "${conf_file}"
else
echo "Calibration file correctly downloaded !"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment