How to get battery status in terminal? I have gingerbread(2.3.6) phone with dropbear installed. I usually access my phone over wifi &amp; run commands in putty.
 I want to get Battery status &amp; percentage in terminal.  Is there any command or program  to obtain battery info ?
Query the system service battery (possibly requires root access)

dumpsys battery


Output would be like


Current Battery Service state:
  AC powered: false
  USB powered: true
  Wireless powered: false
  status: 2
  health: 2
  present: true
  level: 70
  scale: 100
  voltage:3950
  temperature: 260
  technology: Li-ion


level: 70 is the battery percentage here.



Not sure about Android 2.3 but  this is relevant for at least Android 4.2.1 and above:

(Prefix adb shell next to every command to run the command using adb.)


This would give you a list of all the historical broadcasts as well as the sticky ones: 


dumpsys activity broadcasts


In the output search:


Sticky action android.intent.action.BATTERY_CHANGED:


The lines next to it, until you encounter a new sticky broadcast, are useful to us. In my devices, they are listed as:


Intent: act=android.intent.action.BATTERY_CHANGED flg=0x60000010
Bundle[{icon-small=17302819, present=true, scale=100, level=100, technology=Li-ion, status=4, voltage=4140, invalid_charger=0, plugged=0, health=2, temperature=200}]


Assuming that your Android has grep utility, you can shorten the search by using:


dumpsys activity broadcasts | grep -A2 "Sticky action android.intent.action.BATTERY_CHANGED:"


(Source: Monitoring the Battery Level and Charging State)
Alternative: it is possible to query the battery info from /sys  or I should say the Linux kernel.

/sys/class/power_supply/battery/ has some files with useful information. The file named capacity is equivalent to current battery percentage. You can get an accumulated info from uevent file as well. 

For more and related info, read my answer here.