当使用CFExecute和PsExec运行Git操作时,如何克服部分批处理文件执行问题?
我遇到了一个奇怪的问题,尝试了很多不同的方法 目标是让用户单击网页上的一个按钮,该按钮将在其他几个服务器上执行批处理文件 我正在使用ColdFusion 8。当用户单击该按钮时,CFExecute启动PSExec.exe以在远程计算机上执行该文件 摘自bat文件当使用CFExecute和PsExec运行Git操作时,如何克服部分批处理文件执行问题?,git,batch-file,coldfusion,psexec,cfexecute,Git,Batch File,Coldfusion,Psexec,Cfexecute,我遇到了一个奇怪的问题,尝试了很多不同的方法 目标是让用户单击网页上的一个按钮,该按钮将在其他几个服务器上执行批处理文件 我正在使用ColdFusion 8。当用户单击该按钮时,CFExecute启动PSExec.exe以在远程计算机上执行该文件 摘自bat文件 cd c:\web\www >> \\firstmachine\c$\web\qa\html\RA\ra.log git pull origin master >> \\firstmachine\c$\web\q
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
c:\web\qa\html\RA\PsExec.exe\\othermachine-u domain\admincount-pc:\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会拉动aaa,而不是www。
在这些情况下,日志文件在第一次成功拉取后没有显示任何内容,就好像进程中止了一样,但我找不到任何异常的内容
任何想法都非常感谢 您可以尝试使用CALL命令,并将两个块都放在单独的标签中。从外部程序运行批处理文件时,需要指定退出/b[错误代码]。若batch执行第一个git pull并将成功代码返回给调用它的对象,可能会发生什么情况。以下结构仅在成功执行这两个部分后才会发送
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
最后,我取出了批处理文件,并对每个操作使用单独的CFExecute命令。您是否尝试添加requesttimeout,以确保在不使coldfusion超时的情况下为其提供足够的时间?如果在一个单独的线程中运行一个,会发生什么?@steve我没有设置超时,但是脚本运行得很快。coldFusion页面在几秒钟后返回。从命令行运行可以工作,但仍然需要不到10秒的时间。如果在每个cfexecute标记后输出一些文本,两个字符串都会显示吗?我知道这听起来像是一个懒散的答案,但是如果您为另一个调用创建第二个批处理文件,并在第一个调用运行后通过cfexecute调用它,这会工作吗?