0

I'm trying to write a bash script (on my mac) that will get the SDK version and the name of the processor (and use it later) from an android device. I assume the processor will be intel or arm.

so far, I have:

#!/bin/bash

echo "HI $USER" 

# get the sdk version
SDK = $(adb shell getprop ro.build.version.sdk | tr -d '\r')

PROCESSOR = arm
# get processor type (arm or intel)
if ["$(adb shell cat /proc/cpuinfo | tr -d '\r' | grep Processor | grep ARM)" = ""]
then
    PROCESSOR = intel
fi

echo $SDK
echo $PROCESSOR

and I get the following errors: line 6: SDK: command not found line 8: PROCESSOR: command not found line 43: [Processor : ARMv7 Processor rev 0 (v7l): command not found

But when I write:

echo $(adb shell getprop ro.build.version.sdk | tr -d '\r')

I see the correct version of the SDK.

can you plz help? I must be missing something because it should be super easy..

lmaayanl
  • 378
  • 1
  • 2
  • 15

1 Answers1

1

Get rid of the spaces before and after the = sign. For example change

    SDK = $(adb shell getprop ro.build.version.sdk | tr -d '\r')

to

    SDK=$(adb shell getprop ro.build.version.sdk | tr -d '\r')

Do this for all the variables.

For more on this Bash script variable declaration - command not found

Community
  • 1
  • 1
Ashraf Purno
  • 1,065
  • 6
  • 11
  • It worked! (also removed the spaces in the if statement), I knew it was something stupid.. Thank you very much! :) – lmaayanl Dec 24 '15 at 10:22