AMSTracker and sms programing code for applescript and terminal

I started out a project for my mac which uses the amstracker app and the sms device embedded in all macbooks.

i found some line of code online which can help me figure out the coordinates displayed in terminal across to the apple script.

unfortunately, for now i can only access the asm from the terminal.

So i started to have some trouble with the negative number 1,and since i dont know terminal code, does anyone think they could help me translate?

heres the code…

set za to (do shell script "amst=\"$(System/Library/Components/AMSTracker -su .01 -t .01)\"
numbers=\"$(echo \"$amst\" | sed '1d' | awk '{print $1}' | sed 's/$/\\\\/' | tr -d '\\n' | sed 's/\\\\\\\\*$//' | sed 's/\\\\/ + /g')\"
lines=\"$(echo \"$amst\" | grep -c '')\"
za=\"$(echo \"$total\" / $lines | bc -l | sed 's/\\..*//')\"
if [ -z \"$za\" ];then za=0; fi
echo \"$za\"")

za is the variable i was using.

this script lets you see the position of your computer in relation to a rolling movement.
if you wanted to see the back and forth movement i know that all you have to do is change the 1 to a 3 in the {print $1} section, thats about all i know.

now the problem is that when i start using this code it gives me an output of -1 for the setting of 1 and 3 but an output of just - instead of -1 for the 2 setting.

any help? pleeeeeasee?

thanks in advance!