perl -w batt_mon.pl > 20091207bat.log
#!/usr/bin/perl -w print "# time\tlevel\t%chrg\tsec\tmah\tmVolts\tstate\tchg/dis\n"; while(1) { $now = time; @lines = `lshal | grep batt`; @level = split ' ', $lines[1]; @pct = split ' ', $lines[4]; @remtime = split ' ', $lines[10]; @mah = split ' ', $lines[12]; @mv = split ' ', $lines[17]; @st = split ' ', $lines[0]; @chrg = split ' ', $lines[8]; @disc = split ' ', $lines[9]; $cd = substr($chrg[2],0,1) . "/" . substr($disc[2],0,1); print "$now\t$level[2]\t$pct[2]\t$remtime[2]\t$mah[2]\t$mv[2]\t$st[2]\t$cd\n"; sleep 60 - time%60; }