[英]Windows batch file - The system cannot find the batch label specified
[英]svn head revision from a remote repository in windows batch file - the system cannot find the file specified
如何在Windows批處理文件中獲取遠程存儲庫的SVN版本號? 我想檢查條件,當用戶輸入空白時,我必須獲得HEAD修訂版。
我正在使用以下代碼段獲取修訂號。 盡管for循環返回有關遠程SVN服務器位置的所有必要信息,包括修訂號。 批處理文件仍然拋出系統無法找到指定的文件 ,並且變量%SVN_VERSION%仍然為空。
在下面提到的代碼中,%SVN_PATH%指向遠程服務器URL
set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
if "%SVN_VERSION%" =="" (
for /f "delims=: tokens=1,2" %%a in ('svn info %SVN_PATH%') do (
if "%%a"=="Revision:" (
set /a SVN_VERSION=%%b
)
)
)
謝謝
正如我在評論中提到的那樣,您可以使用svnversion command
直接獲得修訂。
@echo off
set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
if "%SVN_VERSION%"=="" (
for /f %%a in ('svnversion') do set "SVN_VERSION=%%a"
)
exit /b 0
編輯
編輯
根據您的評論並嘗試猜測,如果您知道remote_url,以下命令應該可以使用
@echo off
rem Edit remote_url
set /p "remote_url=Please specify the SVN repo url http://....." || goto:EOF
set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
if "%SVN_VERSION%"=="" (
for /f "delims=: tokens=1,2" %%a in ('svn info %remote_url%') do (
if "%%a"=="Revision" ( set SVN_VERSION=%%b )
)
)
exit /b 0
編輯
這也應該起作用,因為我已經看到了輸入內容
@echo off
set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
if "%SVN_VERSION%"=="" (
for /f "tokens=1,2" %%a in ('svn info %SVN_PATH% ^|findstr /ic:"Revision"') do set SVN_VERSION=%%b
)
exit /b 0
說明:
您的錯誤是與delims=:
在一起的,因為:
不是tokens
的一部分,所以比較出錯。 另外,默認的delims
是空格,因此這里不需要指定delims,因為該行分為兩部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.