[Discuss] Bash script help

John Blomfield jabfield at shaw.ca
Sat Mar 1 15:28:38 PST 2014


Solved! This seems to work ok.

DEVICENUM=$(adb devices | grep 3230ce87e28a70b9)

NUM=( $DEVICENUM )

TEMP=${NUM[0]}

if [ "$TEMP" != "3230ce87e28a70b9" ] ; then  echo 'Error' ; else echo 
'OK' ; fi

John

On 03/01/2014 12:16 PM, John Blomfield wrote:
> Ooops some corrections!
>
> On 03/01/2014 12:13 PM, John Blomfield wrote:
>> I want to test that my Android device is connected to my PC usb 
>> before doing other stuff on the ADT sdk in the script ...............
>>
>> ................
>> adb devices
>>
>> #results in
>> List of devices attached
>> 3230ce87e28a70b9        device
>> # if its connect or
>> List of devices attached
>>
>> # an empty list if its not if I run
>>
>> adb devices | grep 3230ce87e28a70b9
>>
>> # I get
>> 3230ce87e28a70b9        device
>>
>> #How do I extract the number 3230ce87e28a70b9 as a variable 
>> $DEVICENUM so I can test it in an "if" statement e.g.
>>
>> if [ 3230ce87e28a70b9 = $DEVICENUM ] ; then 
>> ......................more stuff
>>
>> Thanks John
>>
>>
>>
>
>


-- 
John Blomfield
Delivered by Thunderbird Email on Linux OpenSuse-KDE4

Old John B's Linux Notes http://www.oldjohnbslinux.wordpress.com




More information about the Discuss mailing list