#!/bin/sh # # usage: # ./quacks-ingredients-make-copy-gcodes Tests_L # Uses # quacks-ingredients-L$l,Tests_L.auto.stl # to make # quacks-ingredients-L$l,Tests_L.auto.gcode # and then edits them and copies them to the SD card as # PREPARED/Q$l.G set -e f=$1 shift lhs=quacks-ingredients-L gh () { g=$lhs$l.auto.gcode h=/media/sd/PREPARED/Q$l.G } for l in 1 2 3 4 5; do gh cura -s $lhs$l,$f.auto.stl -o $g case $l in 1|2|3|4) perl -i~ -pe 's/^/;/ if m/^M140 S0\b.*\n/' $g ;; esac perl -i~ -ne ' $l =~ s/^/;/ if m/^M400/; $l .= "G91\nG1 Z5\nG90\n" if m/^M84/; print $l or die $!; $l = $_; END { print $l or die $!; } ' $g done exec 3>${lhs}234.auto.gcode for l in 2 3; do gh perl -pe 's/^/;/ if m/^M104 S0\b/ || (m/^M84/..0)' $g >&3 done for l in 4; do gh cat $g >&3 done umount /media/sd >/dev/null 2>&1 ||: mount /media/sd for l in 1 2 3 4 5 234; do cp $g $h done umount /media/sd mount /media/sd for l in 1 2 3 4 5 234; do gh cmp $g $h ls -l $h done umount /media/sd