maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Help - Bash script - SOLVED you can close this thread ;) a new package is coming for us (https://talk.maemo.org/showthread.php?t=80152)

santiago 2011-11-20 08:45

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

bingomion 2011-11-20 11:21

Re: Help - Bash script
 
good script :)
I googled, found this:
http://talk.maemo.org/showthread.php?t=49904
hope it helps

santiago 2011-11-20 11:42

Re: Help - Bash script
 
Quote:

Originally Posted by bingomion (Post 1126293)
good script :)
I googled, found this:
http://talk.maemo.org/showthread.php?t=49904
hope it helps

it's yet in the code, the problem is not this, but the check code and the restore code about the used profile ;)

Zas 2011-11-20 12:17

Re: Help - Bash script
 
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"

santiago 2011-11-20 12:24

Re: Help - Bash script
 
Quote:

Originally Posted by Zas (Post 1126307)
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"

i'm using this line

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
becouse i have to remove the "string" output line and keep just the profile in the quotations.. The problem that i have is that the script does everythin i wrote, but it doesnt load the right profile couse i cant find the error..

santiago 2011-11-20 12:29

Re: Help - Bash script
 
Quote:

Originally Posted by Zas (Post 1126307)
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"

Oh my god u saved my life thx!!!!!!!! u made my day!!!!!
i was doing a stupid work :D it was not needed

joerg_rw 2011-11-20 12:33

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

santiago 2011-11-20 12:37

Re: Help - Bash script
 
Quote:

Originally Posted by joerg_rw (Post 1126316)
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

i tried using functions but i was worse for me :)

joerg_rw 2011-11-20 12:46

Re: Help - Bash script
 
Quote:

Originally Posted by santiago (Post 1126320)
i tried using functions but i was worse for me :)

where's the problem?

If you got 2 or more locations that look like

Code:

...
A
B
C
D
...

then you get *one*

Code:

myABCDfunction()
{
  A
  B
  C
  D
}

and replace each occurrence of the four lines A B C D by
Code:

...
myABCDfunction
...




If you got
Code:

B 1
at one location and
Code:

B 2
at another, then do
Code:

myABCDfunction()
{
  A
  B $1
  C
  D
}

and call like
Code:

...
myABCDfunction 1
...
myABCDfunction 2
...


[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]

santiago 2011-11-20 12:49

Re: Help - Bash script
 
Quote:

Originally Posted by joerg_rw (Post 1126322)
where's the problem?

If you got 2 or more locations that look like

Code:

...
A
B
C
D
...

then you get *one*

Code:

myABCDfunction()
{
  A
  B
  C
  D
}

and replace each occurrence of the four lines A B C D by
Code:

...
myABCDfunction
...

If you got
Code:

B 1
at one location and
Code:

B 2
at another, then do
Code:

myABCDfunction()
{
  A
  B $1
  C
  D
}

and call like
Code:

...
myABCDfunction 1
...
myABCDfunction 2
...


i did it :D i didnt rest for one night i was linea vampire ... now i try :) and i'll add a code here in a zip file


All times are GMT. The time now is 04:53.

vBulletin® Version 3.8.8