0

私は奇妙な問題に遭遇し、多くの異なることを試みました。

目標は、他のいくつかのサーバーでバッチファイルを実行するWebページのボタンをクリックするようにユーザーに指示することです。

私はColdFusion8を使用しています。ユーザーがボタンをクリックすると、CFExecuteはPSExec.exeを起動して、リモートマシンでファイルを実行します。

batファイルからの抜粋

cd c:\web\www >> \\firstmachine\c$\web\qa\html\RA\ra.log
git pull origin master >> \\firstmachine\c$\web\qa\html\RA\ra.log

cd c:\web\aaa >> \\firstmachine\c$\web\qa\html\RA\ra.log
git pull origin master >> \\firstmachine\c$\web\qa\html\RA\ra.log

コマンドプロンプトから実行すると、gitは正しく実行され、wwwとaaaからプルします。ログファイルには、すべてが期待どおりに機能したことが示されています。

c:\web\qa\html\RA\PsExec.exe \\othermachine -u domain\adminaccount -p <password> c:\web\qa\html\RA\script.bat

CFExecuteを使用してCFから同じコマンドを実行すると、gitはwwwのみをプルし、aaaはプルしません。

<cfexecute name="c:\web\qa\html\RA\PsExec.exe" 
       variable="var" arguments="\\othermachine -u 
       domain\adminaccount -p <password> c:\web\qa\html\RA\script.bat" 
       timeout="50"> 
</cfexecute>

行を入れ替えると、gitはwwwではなくaaaをプルします。このような場合、最初にプルが成功した後は、プロセスが中止されたかのようにログファイルに何も表示されませんが、異常なことは何も見つかりません。

どんな考えでも大歓迎です!

4

2 に答える 2

1

CALLコマンドを使用して、両方のブロックを別々のラベルに入れることができます。外部プログラムからバッチファイルを実行する場合は、exit /b[error_code]を指定する必要があります。バッチが最初のgitpullを実行し、成功コードをそれを呼び出したものに返すと、おそらく何が起こるでしょう。以下の構造は、両方の部分が正常に実行された後にのみ送信されます。

SET _err_lvl=0
CALL :pull_www
CALL :pull_aaa

IF %_err_lvl% EQU 0 exit /b 0

:pull_www
cd c:\web\www >> \\firstmachine\c$\web\qa\html\RA\ra.log
git pull origin master >> \\firstmachine\c$\web\qa\html\RA\ra.log
IF %ERRORLEVEL% NEQ 0 SET _err_lvl=1
:end_pull_www
GOTO: eof

:pull_aaa
cd c:\web\aaa >> \\firstmachine\c$\web\qa\html\RA\ra.log
git pull origin master >> \\firstmachine\c$\web\qa\html\RA\ra.log
IF %ERRORLEVEL% NEQ 0 SET _err_lvl=1
:end_pull_aaa
GOTO: eof
于 2013-02-15T19:20:53.803 に答える
0

結局、バッチファイルを取り出して、アクションごとに個別のCFExecuteコマンドを使用することになりました。

于 2017-07-18T22:10:56.047 に答える