![]() |
Help - Bash script - SOLVED you can close this thread ;) a new package is coming for us
hi guys, i'm working with bash, i'm creating a script that check the battery status and the wall carger status to do some things like keep battery life disabling some features (wifi, 3g mode, ringtone, vibration, bluetooth, fmradio, etc)
can somone help me? the script has to save the current profile if different from silent, i made some mistakes and i'm a little bit confused with it becouse it doesnt save the right used profile. this is the code i made **** the code is in test for that i left "battery.charge_level.percentage = " empty to test it better |
Re: Help - Bash script
|
Re: Help - Bash script
Quote:
|
Re: Help - Bash script
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"
|
Re: Help - Bash script
Quote:
Code:
run-standalone.sh dbus-send --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_profile | grep "string" | sed s/' string '/''/g > /home/user/profilo.txt && sleep 2 |
Re: Help - Bash script
Quote:
i was doing a stupid work :D it was not needed |
Re: Help - Bash script
For God's sake please use functions () { }; in your script
And attach scripts here to tmo as attachment, rather than using pastebin which will vanisch in a week, or month, or year the latest BTW if you definitely need bash then you should use #!/bin/bash Your shebang is calling ash aka messybox on a standard maemo system /j |
Re: Help - Bash script
Quote:
|
Re: Help - Bash script
Quote:
If you got 2 or more locations that look like Code:
... Code:
myABCDfunction() Code:
... If you got Code:
B 1 Code:
B 2 Code:
myABCDfunction() Code:
... [edit] another comment: when you need to use sudo then you obviously don't run the script under root, so you don't need to use run-standalone (though it doesn't hurt). To do arbitrary commands via sudo you probably need to tweak sudoers config in /etc/sudores.d/yourfile a bit. [/edit] |
Re: Help - Bash script
Quote:
|
Re: Help - Bash script
right like this ? i attached the file
i can use this to compare check='cat /home/user/.profiled/current' if [ $profilo = $check ]: then ...... i did a long work :D i could cut the way and the time :D |
Re: Help - Bash script
ok maybe the script works, how can i compare functions with if then else?
i wrote if 1rstcheck then echo "1rst check exists" else 2ndcheck then echo "2nd check exists" else 3rdcheck then echo "3rd check exists" but it doesnt work... |
Re: Help - Bash script
Quote:
Code:
if condition1; then Code:
#! /bin/sh If you end up using functions, bash provides scope for variables (unlike standard Bourne shell). Code:
#! /bin/bash Code:
foo="$(cat "$filename")" And finally, you may want to proect your script against unset variables. Code:
test "$variable" = "yes" |
All times are GMT. The time now is 20:13. |
vBulletin® Version 3.8.8