#!/bin/ksh # lookforspreadsheet.ksh # RJM Programming # February, 2023 # Look for Spreadsheets downloaded off hello_get.html HTML and hello_get.cgi Perl # crontab usage supply an additional argument (onto a first emailee argument, perhaps) ... or to do as a one off execution usage # Thanks to ... # https://www.unix.com/unix-for-dummies-questions-and-answers/123644-converting-binary-file-readable-format-ksh.html # https://stackoverflow.com/questions/26968159/list-of-files-modified-1-hour-before # https://www.unix.com/shell-programming-and-scripting/247464-awk-combined-if.html # https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command one="1"; two="2"; emailto=""; if [ ! -z "$1" ]; then if [ "`echo $1 | tr '@' 'x'`" != "`echo $1`" ]; then emailto="$1"; shift; fi fi while test "$one" -ne "$two" ; do axls=`find $HOME/Downloads -name "perl*.xls*" -type f -mmin 1`; if [ ! -z "$axls" ]; then # res=`hexdump -C "${axls}" | sed -e 's/.|./.!@!/g' | cut -f2 -d '|' | sed -e 's/.!@!./.|./g' | tr -d '\n' | tr -d "'" | cut -d':' -f 2- | grep '.8.8.8.8./.m.a.c.o.s._.s.a.y._.r.e.c.o.r.d...p.h.p.?.d.o.c.r.o.n.w.o.r.k.=.s.a.y.' | sed -e 's/..../~/g' | sed 's/[%][.]2[.]0/s//"/g' | awk -F'.s.a.y.' '{for(i=2;i<=NF;i++){if($i){split($i,a,"~");print a[1] "\t"}}}' | tr -d '&' | sed -e 's/../.~/g' | sed 's/[.]/s///g' | sed 's/[~]/s//./g' | sed 's/\_record\.php\?docronwork\=\t/s//say/g' | sed 's/\_record\.php\?docronwork\=\@/s//say/g' | sed 's/[@]/s//"; sleep 10; /g'` res=`hexdump -C "${axls}" | sed '/[.][|][.]/s//.!@!./g' | cut -f2 -d '|' | sed '/[.][!][@][!][.]/s//.|./g' | tr -d '\n' | sed -e 's/=.s.a.y./=.S.a.Y./g' | tr -d "'" | cut -d':' -f 2- | grep '.8.8.8.8./.m.a.c.o.s._.s.a.y._.r.e.c.o.r.d...p.h.p.?.d.o.c.r.o.n.w.o.r.k.=.S.a.Y.' | sed '/[.][.][.][.]/s//~/g' | sed '/[%][.]2[.]0/s//"/g' | awk -F'.S.a.Y.' '{for(i=2;i<=NF;i++){if($i){split($i,a,"~");print "say " a[1] "@";}}}' | tr -d '&' | sed '/[.][.]/s//.~/g' | sed '/[.]/s///g' | sed '/[~]/s//./g' | sed '/\_record\.php\?docronwork\=\@/s//SaY/g' | sed '/[@]/s//"; sleep 10; /g'` if [ ! -z "$res" ]; then if [ -z "$1" -a -z "$emailto" ]; then echo $res > /tmp/idea.ksh; ksh /tmp/idea.ksh &; else if [ ! -z "$emailto" ]; then echo $res | sed -e 's/%/%25/g' -e 's/ /%20/g' -e 's/!/%21/g' -e 's/"/%22/g' -e 's/#/%23/g' -e 's/\$/%24/g' -e 's/\&/%26/g' -e 's/'\''/%27/g' -e 's/(/%28/g' -e 's/)/%29/g' -e 's/\*/%2a/g' -e 's/+/%2b/g' -e 's/,/%2c/g' -e 's/-/%2d/g' -e 's/\./%2e/g' -e 's/\//%2f/g' -e 's/:/%3a/g' -e 's/;/%3b%0a%0a/g' -e 's//%3e/g' -e 's/?/%3f/g' -e 's/@/%40/g' -e 's/\[/%5b/g' -e 's/\\/%5c/g' -e 's/\]/%5d/g' -e 's/\^/%5e/g' -e 's/_/%5f/g' -e 's/`/%60/g' -e 's/{/%7b/g' -e 's/|/%7c/g' -e 's/}/%7d/g' -e 's/~/%7e/g' > /tmp/idea.ksh; # restwo=`echo $res | sed '/"/s//@/g' | sed "/@/s//'/g"` #cat /tmp/idea.ksh | mailx -s "Proposed macos say audio ideas ..." $1; open "mailto:${emailto}?subject=Proposed%20macos%20say%20audio%20ideas%20...&body=`cat /tmp/idea.ksh`"; echo $res > /tmp/idea.ksh; else echo $res > /tmp/idea.ksh; ksh /tmp/idea.ksh &; fi fi fi fi if [ -z "$1" ]; then sleep 60; else two=$one; fi done exit