diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /tools/bin/retry.cmd | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'tools/bin/retry.cmd')
-rw-r--r-- | tools/bin/retry.cmd | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/bin/retry.cmd b/tools/bin/retry.cmd new file mode 100644 index 00000000..c712985c --- /dev/null +++ b/tools/bin/retry.cmd @@ -0,0 +1,45 @@ +@echo off
+rem $Id: retry.cmd $
+rem rem @file
+rem Windows NT batch script that retries a command 5 times.
+rem
+
+rem
+rem Copyright (C) 2009-2013 Oracle Corporation
+rem
+rem This file is part of VirtualBox Open Source Edition (OSE), as
+rem available from http://www.virtualbox.org. This file is free software;
+rem you can redistribute it and/or modify it under the terms of the GNU
+rem General Public License (GPL) as published by the Free Software
+rem Foundation, in version 2 as it comes in the "COPYING" file of the
+rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+rem
+
+rem
+rem Note! We're using %ERRORLEVEL% here instead of the classic
+rem IF ERRORLEVEL 0 GOTO blah because the latter cannot handle
+rem the complete range or status codes while the former can.
+rem
+rem Note! SET changes ERRORLEVEL on XP+, so we have to ECHO
+rem before incrementing the counter.
+rem
+set /a retry_count = 1
+:retry
+%*
+if %ERRORLEVEL% == 0 goto success
+if %retry_count% GEQ 5 goto give_up
+echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), retrying: %*
+set /a retry_count += 1
+goto retry
+
+:give_up
+echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), giving up: %*
+set retry_count=
+exit /b 1
+
+:success
+if %retry_count% NEQ 1 echo retry.cmd: Success after %retry_count% tries: %*!
+set retry_count=
+exit /b 0
+
|