Jump to content

Command Line Sleep


Zimmer

Recommended Posts

Here is a python version of sleep just convert to you OS enjoy! Also please comment on errors or features you want.

CODE:

import time
import sys
drop=False
for i in sys.argv:
    if i == '-m':
        t='m'
    if i == '-min':
        i='min'
    if i == '-hour':
        t='hour'
    else:
        try:
            num=int(i)
        except:
            drop=True
if t=='hour':
    num=int(num)*3600
if t=='m':
    num=int(num)/100
if t=='min':
    num=int(num)
try:
    time.sleep(int(num))
except:
    print 'An Unknown Error Ocurred. Press Enter to Exit'
    raw_input(' ')
    sys.exit(1)

Link to comment
Share on other sites

Is time.sleep(1) on windows the same as time.sleep(1) on linux?

Basically this is a python script to have a sleep command on windows and mac ox x, both I believe don't have a command except if ping to >nul (clumsy). the time.sleep(1) is python module time and the command sleep sleeping for 1 second. This script excepts -m for milliseconds -s for seconds (defaults to that) -min for minutes and -hour for hours. It then scans the arguments and parses them if there is a problem it quits with 1 as a return value (saying it failed) and saying something went wrong.

Link to comment
Share on other sites

C++ Sleep command, made it for my NintendoDS as DevKitARM dont have a sleep command.

void sleep(int secs) {
   int start = time(NULL);
   while ((time(NULL) - start) < secs) {
    //DO NOTHING!
   }
}

Delphi port

procedure sleep(secs:integer);
  var
    start:integer;
begin
  start:=time(nil);
  while (time(nil) - start) < secs) do
    begin
        //DO NOTHING!
    end;
end;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...