scripts/scan.sh

21 lines
1.5 KiB
Bash
Executable File

#!/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 '<scan:ScanJob xmlns:scan="http://www.hp.com/schemas/imaging/con/cnx/scan/2008/08/19" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/" xmlns:fw="http://www.hp.com/schemas/imaging/con/firewall/2011/01/05"><scan:XResolution>600</scan:XResolution><scan:YResolution>600</scan:YResolution><scan:XStart>0</scan:XStart><scan:YStart>0</scan:YStart><scan:Width>2480</scan:Width><scan:Height>3508</scan:Height><scan:Format>Jpeg</scan:Format><scan:CompressionQFactor>0</scan:CompressionQFactor><scan:ColorSpace>Color</scan:ColorSpace><scan:BitDepth>8</scan:BitDepth><scan:InputSource>Platen</scan:InputSource><scan:GrayRendering>NTSC</scan:GrayRendering><scan:ToneMap><scan:Gamma>1000</scan:Gamma><scan:Brightness>1000</scan:Brightness><scan:Contrast>1000</scan:Contrast><scan:Highlite>179</scan:Highlite><scan:Shadow>25</scan:Shadow></scan:ToneMap><scan:ContentType>Photo</scan:ContentType></scan:ScanJob>'
# 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"