Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ 1 [2] >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Adding to torsmo display in dsl-n, Some help required< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 27 2007,18:26 QUOTE

Afaik printf should be used over echo -n due to it being more standardized, (and therefore more portable).

Heh, maybe negatives aren't supported in the busybox version...

If you're using awk, you may as well do all of the parsing in it.
Back to top
Profile PM 
Juanito Offline





Group: Members
Posts: 1601
Joined: Sep. 2005
Posted: Sep. 28 2007,07:19 QUOTE

The awk thing seems to have fixed the problem - the three mini-scripts now look like this:
Code Sample
$ cat .cpufreq.sh
#!/bin/sh
cpufreq-info -mf | awk '{printf $1 " " $2}'
#
$ cat .cpugov.sh
#!/bin/sh
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | awk '{printf $1}'
#
$ cat .laptop_mode.sh
#!/bin/sh
sudo /etc/init.d/laptop-mode status | grep "drive state is:" | cut -b22- | awk '{printf $1}'
#

...and the excerpt from .torsmorc looks like this:
Code Sample
${color red}$hr
${color grey}Uptime:   $color $uptime
${color #ddd}Battery:  $color ${battery}
${color #ddd}CPU Temp: $color ${acpitemp} degC
${color grey}CPU Freq: $color ${execi 180 ~/.cpufreq.sh}
${color grey}CPU Govn: $color ${execi 180 ~/.cpugov.sh}
${color grey}/dev/hda: $color ${execi 180 ~/.laptop_mode.sh}
${color green}$hr$color


Quote
If you're using awk, you may as well do all of the parsing in it.

- after looking at the awk statement in .torsmo_ip I can believe you're right, but after staring at it for 30mins I wasn't feeling much enlightenment  :)
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Sep. 28 2007,12:31 QUOTE

To pass the output to a var:
VAR=`echo Yeah`


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Oct. 02 2007,13:31 QUOTE

In case it helps in future, to get rid of newlines in a pipe without invoking awk or sed or somesuch, do:

Code Sample
 echo 123 | tr -d '\n'


tr is probably more efficient (not that it probably matters much in this case).

Re:

Code Sample
sudo /etc/init.d/laptop-mode status | grep "drive state is:" | cut -b22- | awk '{printf $1}'


This can probably be contracted to:

Code Sample
sudo /etc/init.d/laptop-mode status | awk  '/drive state is/{printf $4}'
Back to top
Profile PM 
Juanito Offline





Group: Members
Posts: 1601
Joined: Sep. 2005
Posted: Oct. 05 2007,07:45 QUOTE

Thanks - the 3 mini-scripts now look like this:
Code Sample
$ cat .cpufreq.sh
#!/bin/sh
cpufreq-info -mf | tr -d '\n'
#
$ cat .cpugov.sh
#!/bin/sh
cpufreq-info -p | awk '{printf $3}'
#
$ cat .laptop_mode.sh
#!/bin/sh
sudo /etc/init.d/laptop-mode status | awk '/drive state is/{printf $4}'
#
Back to top
Profile PM 
9 replies since Sep. 26 2007,13:32 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ 1 [2] >/
reply to topic new topic new poll
Quick Reply: Adding to torsmo display in dsl-n

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code