23 Eylül 2012 Pazar

beep.bat

Sometimes you need to wait a certain amount of time before doing something. But you don't want to check the time constantly. It will be nice if the computer alerts you when the time is up. So, I created a simple BATCH script to achieve this task. All you need if to fire this command:
beep 1:30
And your computer will beep after 1 minute and 30 seconds.

Batch file is below (or here as gist):
:: usage:
::   beep           -- beeps immediately
::   beep 1         -- beeps after 1 sec
::   beep 1:2       -- beeps after 1 min,  2 sec
::   beep 1:2:3     -- beeps after 1 hour, 2 min,   3 sec
::   beep 1:2:3:4   -- beeps after 1 day,  2 hours, 3 min, 4 sec
::
:: invalid usages:
::    beep 1::2
::    beep :1
::    beep 1:
::    beep :1:

@echo off

set part1=
set part2=
set part3=
set part4=

for /f "tokens=1-4 delims=:" %%a in ("%1") do ^
set part1="%%a"& ^
set part2="%%b"& ^
set part3="%%c"& ^
set part4="%%d"

if not x%part4%==x"" (
 sleep %part1%d %part2%h %part3%m %part4%s
) else (
 if not x%part3%==x"" (
  sleep %part1%h %part2%m %part3%s
 ) else (
   if not x%part2%==x"" (
   sleep %part1%m %part2%s
  ) else (
   if not x%part1%==x"" sleep %part1%s
  )
 )
)

echo  ^G

Important note: '^G' represents bell ring character, not two characters '^' and 'G'. You need to replace this two characters with actual bell ring character: [Ctrl+G] (ASCII Code=7). You can generate this character using Notepad++, TextFX > TextFX Tools > Insert ASCII Chart or Character menu option and deleting rest of the table. A bit redundant work :)

Note 2: This implementation relies on sleep command from GNU Win32. This can be implemented also using timout instead of sleep, but you need to convert time to seconds before passing to timeout command.

Make it system command

You need to cd into the directory which beep.bat located in to execute it. If you want to execute it from anywhere, copy the bat file into Windows folder simply.

Hiç yorum yok:

WSO2 ESB + ClientAccesPolicy.xml + CrossDomain.xml

ClientAccesPolicy.xml and CrossDomain.xml files have to be found at root of your services Silverlight and Flex clients to be able to acce...