这是我的情况...我有一个批处理脚本,它清理磁盘空间并通过电子邮件将结果输出作为附件(有点混乱,但我正在迭代)。我希望将该脚本的标准输出插入到cURL帖子的正文中,而不是作为附件插入。
如何获取%JPDIR %% SCRIPTNAME%作为正文而不是附件?
这是我的脚本:
@ECHO OFF
set JPDIR=c:\jp\
for /f "tokens=*" %%i in ('echo %~nx0.txt') do (SET SCRIPTNAME=%%i)
for /f "tokens=*" %%i in ('hostname') do (SET DEVICE=%%i)
del %JPDIR%%SCRIPTNAME%
call :runcommands >> %JPDIR%%SCRIPTNAME% 2>&1
:runcommands
echo ################################################################
echo # %~nx0 run on %date% at %time%
echo ################################################################
@ECHO OFF
SETLOCAL enableextensions
(for /f "tokens=1-3" %%a in ('
WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"
') do (
if not "%%c"=="" (
echo wsh.echo vbNewLine ^& "%%b" ^& " free=" ^& FormatNumber^(cdbl^(%%a^)/1024/1024/1024, 2^)^& " GB"^& " size=" ^& FormatNumber^(cdbl^(%%c^)/1024/1024/1024, 2^)^& " GB"
)
)
) > "%temp%\tmp.vbs"
ECHO Off
cscript //nologo "%temp%\tmp.vbs"
echo .
echo ---- starting cleanup ----
echo .
echo off
del /q C:\System Recovery\Repair\Backup\*.* > nul 2> nul
del /q /s C:\ProgramData\Microsoft\Windows\WER\ReportQueue\*.* > nul 2> nul
del /q c:\windows\temp\*.* > nul 2> nul
taskkill /im:TrustedInstaller.exe /f
del /q C:\Windows\Logs\CBS\*.log > nul 2> nul
del /q C:\Windows\Logs\CBS\*.cab > nul 2> nul
net start TrustedInstaller
net stop wsearch
del "%programdata%\microsoft\search\data\applications\windows\Windows.edb*"
echo .
echo ---- finished cleanup ----
echo .
@ECHO OFF
SETLOCAL enableextensions
(for /f "tokens=1-3" %%a in ('
WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"
') do (
if not "%%c"=="" (
echo wsh.echo vbNewLine ^& "%%b" ^& " free=" ^& FormatNumber^(cdbl^(%%a^)/1024/1024/1024, 2^)^& " GB"^& " size=" ^& FormatNumber^(cdbl^(%%c^)/1024/1024/1024, 2^)^& " GB"
)
)
) > "%temp%\tmp.vbs"
cscript //nologo "%temp%\tmp.vbs"
echo ################################################################
echo # %~nx0 completed on %date% at %time%
echo ################################################################
echo .
echo .
:mailgun
curl.exe -k -v -s --user "api:key-superdupersecretkey" ^
https://api.mailgun.net/v3/wd.domain.com/messages ^
-F from="JPs Scripts <notifications@domain.com>" ^
-F to=notifications@domain.com ^
-F subject="%~nx0 run on %DEVICE% at %DATE% - %TIME%" ^
-F text="%~nx0 run on %DEVICE% at %DATE% - %TIME%" ^
-F attachment=@"%JPDIR%%SCRIPTNAME%" >>null 2>&1
exit /b 0