Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
2) What is the expected output. You also answered that (sort of):
Code:
design capacity: 7800 mAh
3) What is the actual output. This is the part you keep missing.
In other words, what is the command/script/program doing that you do not want, and/or what is the command/script/program not doing that you do want. Is the command outputting the wrong thing? Anything? Error messages?
Often the solution comes from simply asking one more question, why? Why am I running what I'm running? Why do I expect that output? And most importantly, why is it giving me the result that it is? I can't even count the number of times I've run into some wacky problem, started typing up a thread on LQ, and as I'm answering those questions, I find the solution myself before I even hit Submit.
Last edited by suicidaleggroll; 01-13-2016 at 07:12 PM.
01/13/16 07:47:37 PM
/proc/acpi/battery/BAT0/state:remaining capacity: 5387 mAh
/proc/acpi/battery/BAT0/info:last full capacity: 5667 mAh
/proc/acpi/battery/BAT0/state:charging state: charging
I do my best, but I am not perfect.
We all makes mistakes.
Is there a way for my script to output the file name of the script that I invoked to that same file?
For ex:
Invoked by test.sh
01/13/16 07:47:37 PM
/proc/acpi/battery/BAT0/state:remaining capacity: 5387 mAh
I can not figure out why this line 'grep design /proc/acpi/battery/*/capacity >> Battery_State.txt '
does not send the design capacity to the text file.
Can someone help me ?
Quote:
#!/bin/bash
#
# Linux Puppy 6.3.0
#
# Send battery status to file every 5 minutes 10 times
#
count=1
done=0
while [ $count -le 10 ]
do
(( count++ ))
date "+ m/d/%y %r" >> Battery_State.txt
grep remaining /proc/acpi/battery/*/state >> Battery_State.txt
grep full /proc/acpi/battery/*/info >> Battery_State.txt
grep charging /proc/acpi/battery/*/state >> Battery_State.txt
# next line does not work ??
grep design /proc/acpi/battery/*/capacity >> Battery_State.txt
sleep 300 # Update file every 5 minutes
done
See my earlier post on this question. You need to tell us what it DOES do, not just that it doesn't work. Have you actually looked inside /proc/acpi/battery/*/capacity to see if there are any lines that contain the word "design"?
See my earlier post on this question. You need to tell us what it DOES do, not just that it doesn't work. Have you actually looked inside /proc/acpi/battery/*/capacity to see if there are any lines that contain the word "design"?
This is the file it produces.
Quote:
01/15/16 09:33:43 AM
/proc/acpi/battery/BAT0/state:remaining capacity: 5707 mAh
/proc/acpi/battery/BAT0/info:last full capacity: 5741 mAh
/proc/acpi/battery/BAT0/state:charging state: charged
My previous post with the screenshot shows what shows on my screen when I click on the battery icon.
The proc statements were found on the internet and I do not understand how they work.
I can only post what I know and not what I do not understand.
grep is a text searching tool. It searches the file you tell it for the word you tell it, and prints out any lines that match.
Code:
grep design /proc/acpi/battery/*/capacity
will search for the word "design" in a file called "capacity" that's located in /proc/acpi/battery/*/ (the * matches any directory in that location).
Your system either doesn't have a file called capacity in that location, or that file does not contain the word "design". If you want to fix it, you'll need to see what is actually in that file so you can search for the right phrase.
I can't run your script as none of my systems have a /proc/acpi/battery directory. Entries in /proc/acpi are VERY system and distribution-specific, nobody here will be able to test your script unless they just happen to be running the exact same Linux distribution as you on the exact same hardware.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.