#!/bin/bash #get the ip #TODO: store ip in env (faster) ip=$1 echo "printer on $ip" #TODO: state checking #start job # -H 'Origin: http://10.188.17.24' curl "http://$ip/Scan/Jobs" --compressed -H 'Content-Type: text/xml' --data-raw '6006000024803508Jpeg0Color8PlatenNTSC10001000100017925Photo' # get latest job id jobid=$(curl "http://$ip/Jobs/JobList" --compressed -s --output - | grep "JobUrl" | cut -d "/" -f 4 | cut -d "<" -f 1 | sort -n | tail -n 1) echo "jobid: $jobid" # stream job outname="$2" #TODO: default value curl "http://$ip/Scan/Jobs/$jobid/Pages/1" --output "$outname" -H 'Connection: keep-alive' echo "done: $outname"