Active Topics

 


Reply
Thread Tools
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#11
Originally Posted by fhutt View Post
juiceme I get an error in the scrip-

current: not found

Should current be initialized first or something?
Thanks
No, it should work correctly unless there's some typo.
Can you post here the whole script you made so far?
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#12
Code:
#!/bin/sh

current=$(bmestat | grep "battery current" | awk '{print $3}')

echo $current
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#13
Originally Posted by Schturman View Post
Code:
#!/bin/sh

current=$(bmestat | grep "battery current" | awk '{print $3}')

echo $current
Seems to work OK on my device....
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#14
Yes, you're right that does work.
This is what I had:

current = $(bmestat | grep "battery current" | awk '{print $3}' )

echo $current

Note the spaces before and after the = sign and another space before the last bracket.
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#15
Originally Posted by fhutt View Post
Yes, you're right that does work.
This is what I had:

current = $(bmestat | grep "battery current" | awk '{print $3}' )

echo $current

Note the spaces before and after the = sign and another space before the last bracket.
Yes, that was the problem

Shell scripts are notorious in having certain places that you must have whitespace, like conditional expressions, and certain places that you cannot have whitespace, like in variable assignments...

That's the reason why script programming is such an esoteric art, usually beginners have easier time learning some true high-level language like python which has fairly predictable use of whitespace (namely, only as a block forming method, but note that even there is the huge difference between a space and a tab...)
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#16
I see, it's all in the detail.
Could that 'current' line of code be ported to python?
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#17
Originally Posted by juiceme View Post
Seems to work OK on my device....
Yes I know, it was for fhutt
 

The Following User Says Thank You to Schturman For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 23:32.