Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Help - Bash script - SOLVED you can close this thread ;) a new package is coming for us

    Reply
    Page 1 of 2 | 1   2   | Next
    santiago | # 1 | 2011-11-20, 08:45 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by santiago; 2011-11-23 at 13:42. Reason: update

     
    bingomion | # 2 | 2011-11-20, 11:21 | Report

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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    santiago | # 3 | 2011-11-20, 11:42 | Report

    Originally Posted by bingomion View Post
    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Zas | # 4 | 2011-11-20, 12:17 | Report

    You could try "cp /home/user/.profiled/current /home/user/profilo.txt"

    Edit | Forward | Quote | Quick Reply | Thanks

     
    santiago | # 5 | 2011-11-20, 12:24 | Report

    Originally Posted by Zas View Post
    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..

    Edit | Forward | Quote | Quick Reply | Thanks

     
    santiago | # 6 | 2011-11-20, 12:29 | Report

    Originally Posted by Zas View Post
    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 it was not needed

    Edit | Forward | Quote | Quick Reply | Thanks

     
    joerg_rw | # 7 | 2011-11-20, 12:33 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to joerg_rw For This Useful Post:
    reinob

     
    santiago | # 8 | 2011-11-20, 12:37 | Report

    Originally Posted by joerg_rw View Post
    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    joerg_rw | # 9 | 2011-11-20, 12:46 | Report

    Originally Posted by santiago View Post
    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]

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by joerg_rw; 2011-11-20 at 12:53.

     
    santiago | # 10 | 2011-11-20, 12:49 | Report

    Originally Posted by joerg_rw View Post
    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 i didnt rest for one night i was linea vampire ... now i try and i'll add a code here in a zip file

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 1 of 2 | 1   2   | Next
vBulletin® Version 3.8.8
Normal Logout