Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理脚本读取第一行_Batch File - Fatal编程技术网

Batch file 批处理脚本读取第一行

Batch file 批处理脚本读取第一行,batch-file,Batch File,我每天晚上都要在服务器之间批量复制文件夹。 将生成日志文件,并在最后使用Blat.exe发送邮件 我只想在机器人复制失败的情况下发送邮件。 我看到它的唯一方法是读取日志文件的第一行,如果robocopy运行没有问题,则以“Command complete successfully”开头 Command complete successfully. ---------------------------------------------------------------------------

我每天晚上都要在服务器之间批量复制文件夹。 将生成日志文件,并在最后使用Blat.exe发送邮件

我只想在机器人复制失败的情况下发送邮件。 我看到它的唯一方法是读取日志文件的第一行,如果robocopy运行没有问题,则以“Command complete successfully”开头

Command complete successfully.
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
-------------------------------------------------------------------------------
  Started : Tue Feb 18 23:00:01 2014"
所以我想修改我的脚本来阅读第1行,如果它等于“Command complete successfully”,它将绕过blat.exe和电子邮件发送

脚本如下:

@Echo off
SET dizaine=A%time:~0,1%B 
if A1B==%dizaine% goto OK 
if A2B==%dizaine% goto OK 
:ZERO 
SET dizaine=0
goto fin 
:OK 
SET dizaine=%time:~0,1%
goto fin

:FIN 

set a=%Date:~-4%-%Date:~-7,-5%-%Date:~-10,-8%_%dizaine%%Time:~-10,-9%%Time:~-8,-6%%Time:~-5,-3%
echo %a%

set logfile=C:\script\Logs\HW_database_sync%a%.log

net use H: \\x.x.x.x\SPB /USER:nobody nobody >> %logfile%

robocopy  "C:\CIS" H:\DataBase\D /MIR /COPY:DAT /V /FP /NP /LOG+:%logfile% /FFT /R:0 /W:0 /TEE

net use H: /delete

C:/script/blat.exe %logfile% -to servicex@xxx.com -f hw_database_sync@xxx.com -server xxx.xxx.biz
谢谢
关于

set/p complete=只有在日志文件中找不到字符串时,才会启动blat

那根弦不在第一行,是吗

find /i "Command complete successfully" <%logfile% >nul || C:\script\blat.exe %logfile% -to servicex@example.com -f hw_database_sync@example.com -server sub1.example.biz
find/i”命令成功完成“nul | | C:\script\blat.exe%logfile%-到servicex@example.com-f hw_数据库_sync@example.com-server sub1.example.biz
find /i "Command complete successfully" <%logfile% >nul || C:\script\blat.exe %logfile% -to servicex@example.com -f hw_database_sync@example.com -server sub1.example.biz