Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Noob scripting question with android ADB commands Post 302566685 by Onyoursix on Thursday 20th of October 2011 11:41:16 PM
Old 10-21-2011
Noob scripting question with android ADB commands

Hi I'm pretty new to scripting and I've been googling around looking for an answer but have yet to come up with a proper solution. I work with multiple android devices at a time and I'm looking to simplify my life with a script. Basically I'm looking for a script that takes the device ID's and then issues another command with those unique ID's.

Example:
$ adb devices
Outputs:

List of devices attached
a0000012b044c2 device
39353A76314800EC device
464119A50E1E338E device
a00000128c6400 device

So I now need to the script to plug in those 4 ID's into a command like:

$ adb -s a0000012b044c2 push myfile.zip /sdcard/ |
adb -s 39353A76314800EC push myfile.zip /sdcard/ |
adb -s 464119A50E1E338E push myfile.zip /sdcard/ |
adb -s a00000128c6400 push myfile.zip /sdcard/


To be a bit more clear I use the sed command to output the ID's into a file by themselves, I just don't know how to recall those ID's as variables into a command.

So my output file reads:

a0000012b044c2
39353A76314800EC
464119A50E1E338E
a00000128c6400

Now I need to input those ID's into my shell:

$ adb -s 1stIDfromFile push myfile.zip /sdcard/ |
adb -s 2ndIDfromFile push myfile.zip /sdcard/ |
adb -s 3rdIDfromFile push myfile.zip /sdcard/ |
adb -s 4thIDfromFile push myfile.zip /sdcard/

Any help or if someone can point me in the right direction would be appreciated.

Thanks

---------- Post updated at 11:41 PM ---------- Previous update was at 10:16 PM ----------

Well maybe I posted a bit premature, I did some more searching and found the solution to my question. If anyone is interested here is the script I used

#!/bin/sh
adb devices > devices.txt

sed -e s/devices//g -e s/of//g -e s/List//g -e s/attached//g -e s/device//g devices.txt > test3.txt

rm devices.txt

while read line
do
set -- `echo $line | awk -vFS=',' '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10}'`
adb -s $1 reboot recovery | adb -s $2 reboot recovery | adb -s $3 reboot recovery | adb -s $4 reboot recovery | adb -s $5 reboot recovery | adb -s $6 reboot recovery | adb -s $7 reboot recovery | adb -s $8 reboot recovery | adb -s $9 reboot recovery | adb -s $10 reboot recovery
done < test3.txt

exit 0

I know it's a bit messy but it works, one concern that I have is on the last adb command

adb -s $10 reboot recovery

it only picks up $1 and not $10, any idea on that?

Thanks

Last edited by Onyoursix; 10-21-2011 at 12:10 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Noob learning Unix: backup commands

I am trying to learn some unix here and i have some question that i would like to ask: What's the most basic backup command? What is the command to pause a backup? What is the command to resume backup? Can we backup a job that is running ? How can we pause the backup of the job and than... (1 Reply)
Discussion started by: lotusx
1 Replies

2. Android

Example Linux Commands on Android

In case you are interested, here is a partial list of linux-like commands on Android OS: /sbin adbd devmgr recovery dfta init dfta.sh fat.format redbend_ua /system/bin (partial list) sh date netstat mount umount (0 Replies)
Discussion started by: Neo
0 Replies

3. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

4. UNIX for Dummies Questions & Answers

NOOB - Scripting to make an App work

Hello everyone. i work in a school and i ran into an application today that is a real pickle. i know how to make it work, but i would need to script it. The way to make it work would be to have a script check each local user profile on login, see if the directory already exists, do nothing... (27 Replies)
Discussion started by: jscan
27 Replies

5. Shell Programming and Scripting

Noob to Shell Scripting

Hello. I'm attempting to create a shell script to assist me by saving time with one of my hobbies. I am an Android Enthusiast and currently build a few roms for one of the devices. One of the roms I make is ported from a different device to mine (I get the original for the HTC Desire HD and... (3 Replies)
Discussion started by: JHutson456
3 Replies

6. Shell Programming and Scripting

Noob Expect Scripting Question

I'm having some difficulty with convincing Expect to do what I need.. I have a loop that waits for input, a specific phrase of text followed by a single word. I need Expect to capture that word following the specific phrase. It should then store the word in a variable. I'm fairly sure it's... (6 Replies)
Discussion started by: LongLeafTea
6 Replies

7. Shell Programming and Scripting

Shellscript to copy music from handy to pc over Android Development Bridge (ADB)

Hi Friends, I want to copy my .mp4 files from a file of my mobile to my pc using the programm adb (Android Development Bridge). My Script: ./copyfiletopc /sdcard/Playtube ~/musik/PlayTube \.mp4 #!/bin/bash # $1 = from dir # $2 = to dir # $3 = search # adb is the... (2 Replies)
Discussion started by: Bergiu
2 Replies

8. Android

Basic commands for android!!

Hi, I have a n android phone and just rooted it. I access it using 'terminal Emulator'. I performed many basic linux-like commands in the terminal like rm,ls,df,reboot etc and they are working fine. But many of them are not like man <something>, clear,du etc. Can any of you please help to... (20 Replies)
Discussion started by: shekhar_4_u
20 Replies

9. Shell Programming and Scripting

Noob to scripting needs some assistance

Hello, I am in a Unix class and have been out of town. I have been tasked to generate a couple of scripts and ahve never done it before. I have a virtual machine running Ubuntu. The task is below Prompt the system administrator for all valid input parameters Generate a menu to ask which... (1 Reply)
Discussion started by: jkeeton81
1 Replies

10. Shell Programming and Scripting

Total Noob BASH scripting question

Hello All, I have a file of ip addresses called activeips.txt What I'm trying to do is run a simple bash script that has a loop in it. The loop is a cat of the IP addresses in the file. The goal is to run 2 nmap commands to give me outputs where each address in the list has an OS... (11 Replies)
Discussion started by: Dirk_Pitt
11 Replies
xowish(1)							XOTcl Applications							 xowish(1)

__________________________________________________________________________________________________________________________________________________

NAME
xowish - Graphical shell containing object-oriented scripting language XOTcl SYNOPSIS
xowish ?fileName arg arg ...? _________________________________________________________________ DESCRIPTION
xowish is a shell-like application that reads XOTcl commands from its standard input or from a file and evaluates them. In addition to xot- clsh it provides graphical user interface support for TK widgets. XOTcl (XOTcl, pronounced exotickle) is an object-oriented scripting language based on MIT's OTcl. It is intended as a value added replace- ment for OTcl. Scripting languages, like Tcl, are designed for glueing components together, provide features like dynamic extensibility and dynamic typing with automatic conversion, that make them well suited for rapid application development. The basic object system of XOTcl is adopted from OTcl. The object system enables us to define objects, classes, and meta-classes. Classes are special objects with the purpose of managing other objects. ``Managing'' means that a class controls the creation and destruction of its instances and that it contains a repository of methods accessible for the instances. Every object may be enhanced with object-specific methods. XOTcl supports single and multiple inheritance. All relationships in XOTcl, including class and superclass relationships, are com- pletely dynamic and can be introspected. Through method chaining without explicit naming of the intended method, ambiguities in name reso- lution of methods are avoided. This way a shadowed method can be ``mixed into'' the execution of the current method. XOTcl combines the ideas of scripting and object-orientation in a way that preserves the benefits of both of them. It is equipped with sev- eral new language functionalities that help building and managing complex systems. We added the following support: Dynamic Object Aggregations, to provide dynamic aggregations through nested namespaces (objects). Nested Classes, to reduce the interference of independently developed program structures. Assertions, to reduce the interface and the reliability problems caused by dynamic typing and, therefore, to ease the combination of many components. Meta-data, to enhance self-documentation of objects and classes. Per-object mixins, as a means to improve flexibility of mixin methods by giving an object access to several different supplemental classes, which may be changed dynamically. Per-class mixins, as a means to improve flexibility of mixin methods to a class, all instances of the class have access to the mixed in methods like for multiple inheritance, but without the need of intersection classes. Filters as a means of abstractions over method invocations to implement large program structures, like design patterns. Dynamic Component Loading XOTcl integrates the Tcl package loading with architectrual support for integration with object-oriented con- structs. Moreover, it provides tracking/tracing of component loading. KEYWORDS
argument, interpreter, prompt, script file, shell XOWish xowish(1)
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy