bat demo 1

 

netstat -a -o | findstr 7305 > temp.txt
for /f "tokens=5 delims=# " %%i in (temp.txt) do (
tskill %%i
)

pause

 

%0 当前 batch 文件名
%n 第 n 个命令行参数(1 <= n <= 9)
%* 所有的命令行参数

 

@echo off
echo %0
echo %1
if  not "%1" == "" if  "%2" == "" (
echo haha
echo hehe
)

echo exit
pause

 

@echo off
if "%1" == "" goto parameter_error
if not "%2" == "" got parameter_error 

SET MONKEY_OUTPUT=33_Monkey.txt
SET UFS_DDR_VERSION_FILE=00_UFS_DDR_Version_Case.txt
SET collect_log_file=collectlogtime.txt
SET TEMP_FILE=temp.txt

SETLOCAL ENABLEDELAYEDEXPANSION
if not exist %1\%collect_log_file% goto collect_log_time
for /f  %%i in (%1\%collect_log_file%) do (
set line=%%i
echo log_time:!line:~0,8!
goto collect_log_time
)

:collect_log_time
if not exist %1\%UFS_DDR_VERSION_FILE% goto analyze_monkey_log
for /f  %%i in ('findstr /C:"_BOOT" "%1\%UFS_DDR_VERSION_FILE%"') do (
set line=%%i
echo !line:~0,23!
goto analyze_monkey_log
)

:analyze_monkey_log
SETLOCAL DISABLEDELAYEDEXPANSION
if not exist %1\%MONKEY_OUTPUT% (
echo file_not_exist
goto error_end
)

findstr /n /c:"system_uptime"  %1\%MONKEY_OUTPUT% > %TEMP_FILE%
for /f "tokens=6 delims=:]" %%i in (%TEMP_FILE%) do  set endTime=%%i
for /f "tokens=6 delims=:]" %%i in (%TEMP_FILE%) do (
set startTime=%%i
goto calc_total_time
)

:calc_total_time
echo startTime:%startTime%  endTime:%endTime%
set /a totalTime= endTime - startTime

set /a t=totalTime/1000
set /a s=t%%60
set /a m=(totalTime/1000/60)%%60*100/60
set /a h=totalTime/1000/3600


echo total_time:%h%.%m%hour

:::::::::calc Sending event
::    // Sending event #200
findstr /n /c:"Sending event #" %1\%MONKEY_OUTPUT% > %TEMP_FILE%
for /f "tokens=2 delims=#" %%i in (%TEMP_FILE%) do  set event_count=%%i
echo total_event:%event_count%
goto end

:parameter_error
echo parameters_error

:error_end
echo  batch_error_end: %*
:end
if exist %TEMP_FILE%   del /q /f %TEMP_FILE% 

 

 

set /p LOG_PATH=请输入log绝对路径:
java -jar test.jar  %LOG_PATH%

 

posted @ 2016-12-29 08:49  牧 天  阅读(314)  评论(0)    收藏  举报