我编写了一个需要在批处理文件中执行的java程序。当我运行执行批处理文件的程序时,批处理文件将创建并写入相应的日志,但不会运行可执行jar。
我的批处理文件:
SETLOCAL ENABLEEXTENSIONS
SET me=%~n0
SET parent=%~dp0
SET log=C:\apps\HL7\src\Error_log\Pipeline_batch_log.txt
ECHO /* ************************* Error Log Initiated ************************* */ >> %log%
ECHO %DATE:~10,4%:%DATE:~4,2%:%DATE:~7,2%-%TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% >> %log%
ECHO %parent% >> %log%
ECHO %me% >> %log%
CD c:\apps\HL7\src
IF %ERRORLEVEL% NEQ 0 (
ECHO error - CD failed. >> %log%
)
ECHO java -jar HL7toSS.jar "%1" "%2" "%3" "%4" "%3" "%4" >> %log%
java -jar HL7toSS.jar "%1" "%2" "%3" "%4" "%3" "%4">> %log%
DEL c:\apps\HL7\src\%2
IF %ERRORLEVEL% NEQ 0 (
ECHO error - HL7 xml file did not delete. >> %log%
)
ECHO /* ****************************** END OF LOG ****************************** */ >> %log%
EXIT
正如您所看到的,我记录了可执行jar的输出,但它是静默的(我假设因为它没有运行)。我还记录了应该运行的命令;复制此命令并在命令提示符下运行它可以正常工作。
以下是我在日志文件中看到的输出
/* ************************* Error Log Initiated ************************* */
2017:05:31-14:38:16
C:\APPS\HL7\src\
Pipeline_batch
Infile: Inbound_EDI_Files\test_1.txt HL7file: HL7_XML_Files\793723096202_HL7_test_1.xml MPAXMLfile: C:\apps\HL7\src\Processed_SS_Files\successful\793723096202_SS_test_1.xml MPAXMLERRfile: Processed_SS_Files\failed\793723096202_ERR_test_1.xml BIOMEDXMLfile: C:\apps\HL7\src\Processed_SS_Files\successful\793723096202_SS_test_1.xml BIOMEDXMLERRfile: Processed_SS_Files\failed\793723096202_ERR_test_1.xml
java -jar HL7toSS.jar "Inbound_EDI_Files\test_1.txt" "HL7_XML_Files\793723096202_HL7_test_1.xml" "C:\apps\HL7\src\Processed_SS_Files\successful\793723096202_SS_test_1.xml" "Processed_SS_Files\failed\793723096202_ERR_test_1.xml" "C:\apps\HL7\src\Processed_SS_Files\successful\793723096202_SS_test_1.xml" "Processed_SS_Files\failed\793723096202_ERR_test_1.xml"
/* ****************************** END OF LOG ****************************** */
在命令提示符中复制并粘贴相同的命令会产生以下预期结果
c:\APPS\HL7\src>java -jar HL7toSS.jar "Inbound_EDI_Files\test_1.txt" "HL7_XML_Fi
les\793722688601_HL7_test_1.xml" "C:\apps\HL7\src\Processed_SS_Files\successful\
793722688601_SS_test_1.xml" "Processed_SS_Files\failed\793722688601_ERR_test_1.x
ml" "C:\apps\HL7\src\Processed_SS_Files\successful\793722688601_SS_test_1.xml" "
Processed_SS_Files\failed\793722688601_ERR_test_1.xml"
Processing: main
Processing: Convert to XML
Finished: Convert to XML
Processing: Choose
Finished: Choose
Skipping: MPA XSLT operator: Input is not available.
Skipping: MPA Validate operator: Input is not available.
Processing: BIOMED XSLT operator
Finished: BIOMED XSLT operator
Processing: BIOMED Validate operator
Finished: BIOMED Validate operator
Finished: main
c:\APPS\HL7\src>
在尝试运行jar时,您是否看到任何导致批处理文件无提示失败的内容?
编辑:
从命令提示符运行批处理文件本身也有效。问题似乎源于调用程序,这是一个Progress ABL程序。 ABL过程正在执行批处理文件,如下所示:
ASSIGN runthis = "C:\apps\HL7\src\Pipeline_batch.bat " + INpath + " " + HL7path + " " + SSpath + " " + XML-ERRpath.
OS-COMMAND SILENT VALUE(runthis).
由于日志的原因,我们知道传入批处理文件的参数是正确的。
编辑2:
我的本地机器上预期一切正常。只有在服务器上才会出现此问题。我的预感是,这与服务器的Progress安装有所不同,这与我本地机器上的安装有所不同。我现在需要一个进度向导。
答案 0 :(得分:0)
我怀疑问题如下:
正如here所解释的,为了成功运行Java程序,您必须确保正确设置PATH env变量。
当您在开发机器上进行测试时,或者在您自己的用户配置文件中手动启动prod机器上的批处理文件时,PATH是正确的,一切正常。
当你运行ABL程序时,它运行(可能)有不同的环境变量,因此无法找到" java"或者它缺少一些其他重要的配置元素(java库/罐子,也许?)。
尝试查看从内部 ABL执行上下文调用时的PATH值。试试例如:
OS-COMMAND SILENT VALUE("set PATH").
并将其与您所做的事情进行比较"设置PATH"从你的命令行。