Skip to content

Instantly share code, notes, and snippets.

@jsleeio
Last active July 13, 2019 02:59
Show Gist options
  • Save jsleeio/db761636c43029cc0ca73f5f876c36ae to your computer and use it in GitHub Desktop.
Save jsleeio/db761636c43029cc0ca73f5f876c36ae to your computer and use it in GitHub Desktop.
Run Autodesk EAGLE 9.x CAM jobs from commandline
#!/bin/bash
set -e
set -o pipefail
_die() {
echo "eagle-run-cam-job.sh: FATAL: $*" >&2
exit 1
}
[ -n "$1" ] || _die "must specify a board file"
board="$1"
today=$(date +%F)
output="$(basename "$board" .brd)-$today"
eagle="/Applications/EAGLE-9.4.2/eagle.app/Contents/MacOS/eagle"
cam="$HOME/Documents/eagle/cam/Seeed-EAGLE-JSON-2-Layer.cam"
test -x "$eagle" || _die "EAGLE executable must exist (edit me if this was upgraded): $eagle"
test -f "$board" || _die "board file must exist: $board"
test -f "$cam" || _die "CAM file must exist: $cam"
# make sure we have an output directory
mkdir -p "$output"
# clean up gunk from any previous iterations
find "$output" -type f -delete -maxdepth 1 -mindepth 1
"$eagle" -X -dCAMJOB -j"$cam" -o"$(pwd)/$output" "$(pwd)/$board"
( cd "$output"; zip -m -9 "../$output.zip" ./* )
# clean up after ourselves
find "$output" -type f -delete -maxdepth 1 -mindepth 1
rmdir "$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment