title: shell/ batch scripting to direct commands to adb shell
body: <p>I am trying to write a batch(for win) and a shell script for linux to automate key and touch events on a android UI. At the moment in a windows batch file I am starting a adb shell for each event for eg</p>
  
  <pre><code>    :again
  
  adb shell am start -a android.intent.action.MAIN -n com.q.me.fui.activity/.InitActivity
  
  sleep 15
  
  adb shell sendevent /dev/input/event0 3 0 281
  adb shell sendevent /dev/input/event0 3 1 70
  adb shell sendevent /dev/input/event0 1 330 1
  adb shell sendevent /dev/input/event0 0 0 0
  adb shell sendevent /dev/input/event0 1 330 0
  adb shell sendevent /dev/input/event0 0 0 0   
  adb shell sendevent /dev/input/event0 1 330 1
  adb shell sendevent /dev/input/event0 0 0 0
  adb shell sendevent /dev/input/event0 1 330 0
  adb shell sendevent /dev/input/event0 0 0 0
  adb shell sendevent /dev/input/event0 0 0 0
  adb shell sendevent /dev/input/event0 0 0 0   
  
  sleep 5
  
  adb shell input keyevent 82
  adb shell input keyevent 20
  adb shell input keyevent 20
  adb shell input keyevent 22
  adb shell input keyevent 22
  adb shell input keyevent 22
  adb shell input keyevent 66
  
  sleep 5
  
  goto again
  </code></pre>
  
  <p>The above code is infact starting a new adb shell each time. I want to avoid this. I want my batch script to start the adb shell only once and I would like to route the sendevent and other commands to the subshell, ie the adb shell.</p>
  
  <p>Any idea how I can do this in win batch and Lin shell script?</p>