What does this script do? [Perl]

Hi.
First, an absolutely necessary foreword:
I'm planning to buy a ThinkPad T410s. It has a nice special battery chip, making it possible to have much better means of power management.
For instance, one can put in an additional (so called "Ultrabay") battery and the special kernel module "tp_smapi"
(read more about it here: http://www.thinkwiki.org/wiki/Tp_smapi) lets one take control of how it is handled (see below)
The thing is, the default behavior is to drain ultrabay completely, but this causes its capacity to deplete quickly. That's why there are certain tp_smapi's options like "force_discharge" which tell the laptop to ex. drain main battery first, the use ultrabay battery. But it is quite a hassle to manually switch to ultrabay when main runs out, etc.
That's why such script has been created:
http://www.thinkwiki.org/wiki/Talk:Code/tp-bat-balance
It's supposed to manually switch main and ultrabay back and forth to ensure exual discharge all the time, as I understand it.
But I cannot use it in my laptop if I am not 100% sure what it does! It is not really documented, and I'm not a coder.
Understanding bash scripts isn't really rocket science, but with Perl, it is much different.
So I kindly ask you:
Could you please, in normal english describe what it does? (ex. which condition needs to be met to execute a specific command)
Thanks in advance!
PS.: And if you do, I could put the description into ThinkWiki's tp-bat-balance site, so that everybody (not only Perl programmers) know what it does

i no longer have the script open (and i don't feel like reopening) so this is from memory...
warnec wrote:1) how is $thresh defined? What is it supposed to do in these two funtions? Why is it added?
$thresh is defined by the simple `my $thresh = 3` line that you quoted to me.  I assume it's there so that the script doesn't switch batteries the instance that BAT0 hits 99.999%, then back when BAT1 hits 99.998%, then back again when BAT0 hits 99.997% and so on, and so on.
warnec wrote:$bat_remaining[0] > $bat_remaining[1] + $thresh
$bat_remaining[1] > $bat_remaining[0] + $thresh
the first statement means if battery zero's remaining percent is greater than (battery one's remaining percent plus 3), then...; and the second statement is just the reverse, if battery one's remaining percent is greater than (battery zero's remaining percent plus 3), then....  if neither of these statements are true, then the threshold his not met (the two battery's percentages are within 3% of each other) and no battery switching should happen.
warnec wrote:
2) why such a weird (at least to me) syntax?
set_force_discharge(0,1);
set_force_discharge(1,0);
set_force_discharge(0,0);
set_force_discharge(1,1);
set_force_discharge takes two arguments.  the battery to set (BAT0 or BAT1) and the value to set it to (0 = don't discharge, 1 = discharge).
so, the above statements would be equivalent to:
tell BAT0 to discharge
tell BAT1 to not discharge
tell BAT0 to not discharge
tell BAT1 to discharge
which is exactly what you need to do depending on the results of your if statements.
Last edited by brisbin33 (2010-06-14 21:48:57)

Similar Messages

  • HELP What does this Script Mean

    someone told me to go to this website barqs.com and all that came up was a code or java script and i am wondering if i was being fooled or hacked. plz tell me heres the script
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <c:set var="currpage" value="home" scope="request"/>
    <jsp:include page="_dispatch.jsp"/>
    what exactly does it mean can anyone tell me???

    Where are you downloading ML from? Have you bought it?

  • What does this script do? resource://gre/modules/XPCOMUtils.jsm:271

    Firefox (5) hangs, & eventually I get an "Unresponsive script" warning.

    https://developer.mozilla.org/en/JavaScript_code_modules/XPCOMUtils.jsm

  • What does "unresponsive script" warning mean?

    what does "unresponsive script" warning mean?

    I'm having the same problem with Firefox 19 on both OS X and Windows 7. It seems to be tied to Facebook (which I have as a pinned tab). I don't have to force quit though - just hit the 'stop script' button and things proceed as usual.
    I've a bug report into Firefox - if you don't have Facebook open in a tab, I don't know why you're getting the same error message.
    Clinton
    Update: Just received a reply - I'll give it a shot:
    "Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.

  • What does this" touch /var/lock/subsys/oracle9i " used for?

    touch /var/lock/subsys/oracle9i
    this is in oracle auto start scripts.
    What does this" touch /var/lock/subsys/oracle9i " used for?
    Thanks.

    ok,
    this touch in dbora is solely used for dbora. The dbora script will later on remove the file after stop database.
    sample of dbora
    #!/bin/bash
      # chkconfig: 35 99 10   
      # description: Starts and stops Oracle processes
      # Set ORA_HOME to be equivalent to the $ORACLE_HOME
      # from which you wish to execute dbstart and dbshut;
      # Set ORA_OWNER to the user id of the owner of the
      # Oracle database in ORA_HOME.
      ORA_HOME=<Type your ORACLE_HOME in full path here>
      ORA_OWNER=<Type your Oracle account name here>
      case "$1" in
        'start')
           # Start the Oracle databases:
           # The following command assumes that the oracle login
           # will not prompt the user for any values
           su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
           # Start the TNS Listener
           su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
           # Start the Intelligent Agent
           if [ -f $ORA_HOME/bin/agentctl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
           else
              su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_start"
           fi
           # Start Management Server
           if [ -f $ORA_HOME/bin/oemctl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl start oms"
           fi
           # Start HTTP Server
           if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
           fi
           touch /var/lock/subsys/dbora
        'stop')
           # Stop HTTP Server
           if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
           fi
           # Stop Management Server
           if [ -f $ORA_HOME/bin/oemctl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl stop oms sysman/<password>"
           fi
           # Stop the Intelligent Agent
           if [ -f $ORA_HOME/bin/agentctl ]; then
              su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl stop"
           else
              su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_stop"
           fi
           # Stop the TNS Listener
           su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
           # Stop the Oracle databases:
           # The following command assumes that the oracle login
           # will not prompt the user for any values
           su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
           rm -f /var/lock/subsys/dbora
      esac
      # End of script dbora

  • What does this mean:Photoshop 13.1.2 for Creative Cloud Installation failed. Error Code: U44M1P7

    What does this mean:Photoshop 13.1.2 for Creative Cloud Installation failed. Error Code: U44M1P7
    I found the manual update, which worked!
    http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5595&fileID= 5604

    Hi Barbara,
    For failed 13.1.2 update error U44M1P7, Please refer to the solution mentioned in the following threads :
    http://forums.adobe.com/message/5396792#5396792
    http://forums.adobe.com/message/5409050#5409050

  • Why has my monitor suddenly begun to have a moiré pattern all over – it is even showing up on my icons on the dock? It appears to be very thin bright green vertical lines. I have a 2008 iMac which is running 10.6.8. What does this mean?

    Why has my monitor suddenly begun to have a moiré pattern all over – it is even showing up on my icons on the dock? It appears to be very thin bright green vertical lines. I have a 2007 iMac which is running 10.6.8. What does this mean? I've attached some screen shots below.
    Also experiencing some funky issues with my wireless keyboard. With new batteries, it will just stop functioning. Certain keys intermittently won't work. Also the fans go on as soon as I turn the computer on - some times they stay on and sometimes they don't. Ever since upgrading the operating system - I've been having many issues with this iMac. Not happy. Any answers out there?

    Thanks for your reply LexSchellings, There is no disc in the drive and I went through the suggestions you put forward on the phone with Apple support without any luck. I can put a disc in but it pops straight back out again without registering on finder.
    The idea of using an external drive was to enable me to avoid the cost and loss of productivity whilst machine in repair... if I have to take it in to get the old drive removed than I might as well have a new internal drive put in, although I do worry about the reliability of these apple drives given my experience with this one coupled with my limited online research ... on line forums seem to be full of people with the same problem (although perhaps searching such forums is bound to make it seem a common problem as users with perfectly working machines are less likely to post (?)) Your reply suggests that no external drive will work whilst the existing drive is in place.
    As a postscript: I do realise that this is a user forum ...my secondary question was asking if anyone knows how to put forward a case/complaint to Apple... I can't find a link on the support page that would enable me to do so and I was wondering if anyone on this user forum had any ideas/experience..

  • When trying to update my IPad apps I am getting the message "Your Apple ID has been disabled". Still have more than 50$ in my account, so what does this mean ?  What can I do to get my ID enabled again ?

    when I am trying to download IPad updates I get the message "Your Apple ID has been disabled". What does this mean? How do I get my ID enabled again? Still got more than 50$ in my account !

    Reset your Apple ID password here >  Apple - My Apple ID
    More information here >  Apple ID: "This Apple ID has been disabled for security reasons"  appears

  • I'm trying to upgrade to Mountain Lion and I get an error message that says "server error during download; 403 forbidden. What does this mean, what can I do? I had no problem downloading Lion.

    Trying to upgrad to Mountail Lion and got an error message : 403 Forbidden. What does this mean? What can I do? I had no problem when I upgraded to Lion.

    403 Forbidden HTTP status code in response to a request from a client for a web page or resource to indicate that the server refuses to allow the requested action. In other words, the server can be reached, but the server declined to allow the requested access.
    http://en.wikipedia.org/wiki/HTTP_403
    Could you be using a different Apple ID oe such?

  • I am suddenly unable to open my pictures in Adobe Photoshop. It gives the following message: The document "Tina-19.jpg" could not be opened. Photoshop cannot open files in the  "Adobe Photoshop JPEG file" format. What does this mean? I have opened my phot

    I am suddenly unable to open my pictures in Adobe Photoshop. It gives the following message: The document “Tina-19.jpg” could not be opened. Photoshop cannot open files in the  “Adobe Photoshop JPEG file” format.
      What does this mean? I have opened my photos in Adobe Photoshop for years and suddenly I get this message and can't open any of my pictures

    JoeLib wrote:
    You type way faster than me Gene.
    Well, not necessarily in this case.
    According to the time stamp, Gene posted his answer a bit over three hours before you did, Joe.
    Gene's post:       Dec 29, 2014 5:54 PM
    Joe's post:          Dec 29, 2014 8:57 PM

  • What does this message mean:  this apple ID has not yet been used in the iTunes store"? I cant connect using my iphone. But it works in iTunes on my laptop.

    what does this message mean:  this apple ID has not yet been used in the iTunes store"? I cant connect using my iphone. But it works in iTunes on my laptop.

    FAQ apple id http://support.apple.com/kb/HT5622?viewlocale=en_US
    http://support.apple.com/kb/HT1311

  • What does this message mean?  "ITunes has fetected an iPad in recovery mode.  You must restore this iPad before it can be used with ITunes".

    What does this message mean?  "itunes has detected an iPad in recovery mode.  You must restore this iPad before it can be used with ITnes."  How do I restore when every time I connect to my computer I get this message?

    Perhaps the information in this Apple support article will help:
    http://support.apple.com/kb/TS3694#error3004
    Regards.

  • What does this message mean Charging is not supported with this device?

    What does this message mean Charging is not supported with this device?

    You've gotten 2 good answers already, but there's a key assumption in both that you got the message when connecting the iPhone to some other device. If this is the case you can get an adapter in the Apple online store that will allow charging from older devices.
    If, however, this message appears when you are not connected to anything the problem is dirt or moisture in the dock connector at the bottom of the phone. Clean it with a dry toothbrush or air blast.

  • What does this message mean when i dial

    What does this verizon message mean?
    'your call cannot be completed as dialed'
    i got a number on my caller id from my ex's neighborhood
    609-424-xxxx
    its not his (old, home) number, but i am concerned that he got a new number or maybe called from a pay phone--
    he has a history of psychological abuse
    i tried calling the number back from a pay phone from the next county to see if i could find out thatit wasn't him to put my mind at ease..
    but i got the above message
    i dialed the number that was on my caller ID
    would this message come up if it were a payphone that does not take incoming calls?
    why else would i get the message.
    thats the number that came into my caller id, but i am told it can't be completed as dialed..
    i was calling from the 732 area code and did use the full number with the area code
    i tried googling the number and doing a reverse look up
    we live far apart--i don't know anyone else in his town--its too much of a coincidence to just be a wrong number
    there is not enough to file a police report yet

    This seems to suggest that it could be filenames… (see the final posts).
    https://discussions.apple.com/message/7818914?messageID=7818914#7818914?messageI D=7818914
    Replace dashes, underscores, hyphens & any other funky looking characters. Very long filenames of folder paths may cause trouble too.

  • What does this message mean? : "The file name "DSC_0088.jpg" is offline or missing." ?

    What does this message mean? : "The file name "DSC_0088.jpg" is offline or missing."   I am in the process of importing photos from iPhoto (don't really know what I'm doing....) and when I look at one of the imported photos that message pops up.  I know what "DSC_0088.jpg" is.  I don't know what it means that the file is "missing".

    CASpyr,
    Thank you so much for your reply.  I have a couple of bigger issues that I am dealing with: too many photos on my laptop: 40,000! (Of course I have to throw away many of them, but that is time consuming). I have a MacBook Pro and have primarily used IPhoto. I have recently purchased 2 external drives and have transferred my photos to those, but I need a basic education about how photos are stored, copied, etc.  I have recently been told that iPhoto only shows and deals with jpegs, not RAW.  About 1/3 of my photos are RAW, so I purchased Lightroom, so I could do more with those RAW photos.  I have been told by my local Mac store that I need to delete most of my photos from iPhoto, because it's causing problems.  I am reluctant to do so until I am sure that all of the keywords, descriptions and editing I have done to these photos is not lost when deleted from iPhoto. I just watched a tutorial about importing to Lightroom and got out of it that I needed to copy photos from iPhoto to a file on my desktop and then copy to Lightroom.  I did that, it seemed to work.  Then (because of my storage/memory issues) I deleted the photos (just a few as an experiment) from that desktop file.  I'm guessing that is why Lightroom doesn't recognize the the photos.  It seems that (learned from another tutorial) that one uses "Add" , Lightroom is only connecting to the source of the photo, not  actually copying it to the program.  Sounds like I need to use the "Move" feature instead.  My ultimate goal is to store the photos on the 2 external drives and eliminate most of them from my lapop.  So my basic questions have to do with what data (metadata??) is copied from iPhoto to an external drive (RAW???) and what isn't copied. Basic understanding issues,obviously….  I hope this isn't too much to ask.  If you can recommend a book or resource that can explain those basic issues to me I'd appreciate it.  I just got back from a trip and I can't download my new photos until I manage the rest!
    Thanks,
    Nancy

Maybe you are looking for

  • Saving files in Photoshop CS6 Extended (Mac)

    I just got Photoshop CS6 Extended (Mac) and am unable to save files (eg .psd) as a .jpg -- if I select the JPEG option, although that is ticked, it appears in the filename above as .gif or .eps  WHY?? Also, why do I have to select 'Enable' and scroll

  • Issue with MSSQL server connectivity from ODI 10.1.3

    Hi, In one of the interface we are populating data to target table in MSSQL server version 2005. The physical topology connection results successful. Since so long there is no problem and it is running successful. But suddenly I'm facing issues with

  • Actual Cumulative Balance

    Dear all, Is it possible through FS10N see the Cumulative Balance only from the beginning of the actual Fiscal Year? I've notice in fact that Cumulative Balance shows all the items even from privious FY. thanks in advance Alberto

  • Losing changes to library - iTunes Match.

    I have my library set up locally, and iTunes match on. Every time I make changes to my library (such as album/song ratings that affect smart playlists), I update IM but all my changes are lost every time and it reverts back to the library before the

  • HT201303 Dear iTunes Store Support,  I have an Apple ID but I can not buy the application because my Apple ID has been disabled.

    Dear iTunes Store Support, I have an Apple ID but I can not buy the application because my Apple ID has been disabled. Please enable my account so I can buy the application. 1) My account information: Apple ID: ****  2) I do not have a credit card th