1
バッチ内で呼び出している Perl スクリプトは、、、2
またはを返します3
。引数 829 を指定してこの perl スクリプトを呼び出し、スクリプトの終了コードを取得するための構文は何ですか?
Perl.exe listMembership.pl 829 in cmd.exe
@echo off
set retVal=Perl.exe listMembership.pl 829
echo %retVal%
1
バッチ内で呼び出している Perl スクリプトは、、、2
またはを返します3
。引数 829 を指定してこの perl スクリプトを呼び出し、スクリプトの終了コードを取得するための構文は何ですか?
Perl.exe listMembership.pl 829 in cmd.exe
@echo off
set retVal=Perl.exe listMembership.pl 829
echo %retVal%
if /?
コマンドラインでの出力を見てください。拡張機能がなければcmd
、最小公分母のバッチ スクリプトは次のようなものになります。
@echo off
Perl.exe listMembership.pl 829
if errorlevel 4 goto error
if errorlevel 3 goto exit3
if errorlevel 2 goto exit2
if errorlevel 1 goto exit1
if errorlevel 0 goto exit0
:error
echo:Unexpected exit code %ERRORLEVEL%
goto end
:exit3
echo:Forbnicate
goto end
:exit2
echo:Colormaticate
goto end
:exit1
echo:Motorcade
goto end
:exit0
echo:Is this really success?
goto end
:end
echo:Done
次の理由により、errorlevel
チェックは降順でなければならないことに注意してください。
ERRORLEVEL 数値 最後のプログラムが実行された場合に真の条件を指定します 数値以上の終了コードを返しました 指定。