Computer States

Discussion in 'Ruby' started by Brandon B., Dec 18, 2009.

  1. Brandon B.

    Brandon B. Guest

    Hey all,

    I'm looking for a way to programmatically wake the computer up from
    sleep state, preferably at a certain time, rather than after certain
    amount of time, but ill make due with whatever solution there might be.
    any suggestions or help is much appreciated. i've been searching for a
    couple weeks on and off for a way to do this, and can only find the
    wake-on-lan, or wake-on wan (would work fine for some, but id rather
    this feature not fail should the user not have a router or an internet
    connection.)

    Thanks in Advance,

    X
    --
    Posted via http://www.ruby-forum.com/.
     
    Brandon B., Dec 18, 2009
    #1
    1. Advertising

  2. On Thursday 17 December 2009 10:04:20 pm Brandon B. wrote:
    > I'm looking for a way to programmatically wake the computer up from
    > sleep state, preferably at a certain time, rather than after certain
    > amount of time, but ill make due with whatever solution there might be.


    I suspect most BIOSes have this feature, but I have no idea how to access it
    programmatically. I did find this:

    http://sourceforge.net/projects/nvram-wakeup/

    I have no idea how well it works, though, and it's probably going to be
    system-specific.
     
    David Masover, Dec 18, 2009
    #2
    1. Advertising

  3. Brandon B.

    Brandon B. Guest

    > I suspect most BIOSes have this feature, but I have no idea how to
    > access it


    i was thinking about bios features, but being able to access and change
    certain features of it will either give the user alot of hassle or
    myself in having to change things on the many different bios versions
    there are, if it is even possible to change it programmatically, not to
    mention the warning label that would have to be included by going that
    route.

    > programmatically. I did find this:
    >
    > http://sourceforge.net/projects/nvram-wakeup/


    will definetly have to check this out, might be able to salvage
    something from it, with a bit of research.

    > I have no idea how well it works, though, and it's probably going to be
    > system-specific.


    i would like to have it be cross-platform, but i dont have a problem
    with testing for the OS is need be, thanks David.
    --
    Posted via http://www.ruby-forum.com/.
     
    Brandon B., Dec 18, 2009
    #3
  4. On 18.12.2009 05:28, Brandon B. wrote:
    >> I suspect most BIOSes have this feature, but I have no idea how to
    >> access it

    >
    > i was thinking about bios features, but being able to access and change
    > certain features of it will either give the user alot of hassle or
    > myself in having to change things on the many different bios versions
    > there are, if it is even possible to change it programmatically, not to
    > mention the warning label that would have to be included by going that
    > route.


    You probably want to access http://en.wikipedia.org/wiki/ACPI
    How you do that is OS specific, since it's fairly lowlevel. A very
    superficial search for "Ruby ACPI library" didn't produce any real hits,
    so it might be that you have to go low level to call the Windows, Linux,
    and Mac OS X APIs for ACPI.

    However, it is my understanding that ACPI can't wake a computer from a
    Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.

    Hope this helps at least a little.

    --
    Phillip Gawlowski
     
    Phillip Gawlowski, Dec 18, 2009
    #4
  5. Brandon B.

    Brandon B. Guest

    > You probably want to access http://en.wikipedia.org/wiki/ACPI
    > How you do that is OS specific, since it's fairly lowlevel. A very
    > superficial search for "Ruby ACPI library" didn't produce any real hits,
    > so it might be that you have to go low level to call the Windows, Linux,
    > and Mac OS X APIs for ACPI.


    yea, i expected as much, which if fine, i just dont know how to go about
    doing so... maybe there is a way to send a "wake-up" packet to the ram,
    or nvram, and have it execute it from there at a given time? dont know
    too much about what can and cant be performed like that so, if im way
    off base, please forgive me.

    > However, it is my understanding that ACPI can't wake a computer from a
    > Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.
    > Hope this helps at least a little.


    yea it has helped, thank you. i have found a linux wake up procedure
    that i might be able to tether to my needs, if it works

    <CODE>
    #!/usr/bin/ruby
    require 'time'
    wake_time = Time.parse(ARGV[0])
    wake_time += 24 * 60 * 60 if wake_time < Time.now
    File.open('/proc/acpi/alarm', 'w') {|f| f << wake_time.utc.strftime
    (%Y-%m-%d %H:%M:%S')}
    system('/etc/acpi/sleep.sh force')
    </CODE>

    like i said, this is for linux, obviously, which if it works takes out
    one of my issues, but what i dont know is if there is anything like the
    above file locations for windows or mac?

    well, ill keep looking around, maybe i can dig up something else using
    this as a search tool, any additional help or advice is much
    appreciated.
    --
    Posted via http://www.ruby-forum.com/.
     
    Brandon B., Dec 18, 2009
    #5
  6. On 18.12.2009 21:00, Brandon B. wrote:

    > yea, i expected as much, which if fine, i just dont know how to go about
    > doing so... maybe there is a way to send a "wake-up" packet to the ram,
    > or nvram, and have it execute it from there at a given time? dont know
    > too much about what can and cant be performed like that so, if im way
    > off base, please forgive me.


    You'd've to read the ACPI spec, I'm afraid, what does what, if you want
    to go really, really low level, since I stay away from the Dark Arts. ;)

    > like i said, this is for linux, obviously, which if it works takes out
    > one of my issues, but what i dont know is if there is anything like the
    > above file locations for windows or mac?


    With Windows, there's the win32api gem (pre-installed in the Once Click
    Installer and/or the new RubyInstaller), providing access to the Windows
    API, so you can call the Windows system calls to send the computer to
    sleep. Or, maybe, you can shell out to "shutdown", but I'm not well
    versed in Windows CLI tools, at least to send to computer to sleep. I'm
    pretty sure that WakeOn needs an API call, though.

    With Macs, and this is from my dim memory, there's CocoaRuby (I think
    that's what it is called, googling for "cocoa ruby" should unearth
    something), which accomplishes roughly the same as the win32api gem.

    Keep in mind, you can run into binary compatibility issues on Windows
    (depending on the Ruby variant installed, there's mswin32, and mingw32,
    the latter being included in the new RubyInstaller), as well as on Mac
    (depending on the Mac Os X API changes).

    And that ain't even touching on JRuby. So, "true" cross-platform
    compatibility will be difficult, to say the least.

    Mind, just pick the Ruby versions you are able to report, and you'll be
    fine, don't let me scare you. :)

    --
    Phillip Gawlowski
     
    Phillip Gawlowski, Dec 18, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yttrium
    Replies:
    7
    Views:
    2,594
    Yttrium
    Oct 15, 2003
  2. Fred Bartoli
    Replies:
    7
    Views:
    620
    Fred Bartoli
    Feb 7, 2004
  3. Enno Luebbers
    Replies:
    3
    Views:
    962
    Ben Jones
    Sep 7, 2005
  4. Jonathan Amend

    Using SQL Server for session states

    Jonathan Amend, Jul 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    362
    bruce barker
    Jul 19, 2003
  5. John
    Replies:
    2
    Views:
    340
    MS News \(MS ILM\)
    Aug 20, 2003
Loading...

Share This Page