简体   繁体   English

Tomcat调用Windows bat文件的某处是否有1000个字符的限制?

[英]Is there a 1000 character limit somewhere from Tomcat calling Windows bat file?

I have a Tomcat servlet that is calling a Windows BAT file via java's ProcessBuilder. 我有一个Tomcat servlet,它通过java的ProcessBuilder调用Windows BAT文件。 Seems that if I have more than 1000 characters on a command within the BAT file then the process fails with a return code 128 back from ProcessBuilder. 似乎如果BAT文件中的命令上的字符超过1000个,则该过程将失败,并从ProcessBuilder返回128。

Its very strange - I can edit the BAT file and put a few spaces in the offending command and cause the error...or I can remove the spaces and everything runs cleanly. 这非常奇怪-我可以编辑BAT文件,并在令人反感的命令中放置一些空格并导致错误...或者我可以删除这些空格,然后一切正常运行。

Any ideas? 有任何想法吗?

Odds are much greater that you have exceeded the shell's command name limit. 如果您超出了Shell的命令名限制,则可能性更大。

Within the BAT file, the CMD.EXE program is reading the lines, not Tomcat. 在BAT文件中,CMD.EXE程序正在读取行,而不是Tomcat。 Tomcat was responsible for launching the CMD.EXE process (with the provided BAT file argument). Tomcat负责启动CMD.EXE进程(使用提供的BAT文件参数)。

It is not a limit of tomcat of java. 它不是Java的tomcat的限制。 It is a limit of Windows. 这是Windows的限制。 BTW even Unix systems have such kind of limit just it is typically much bigger. 顺便说一句,即使是Unix系统也有这种限制,只是通常更大。

So, to work around the problem do not create so long command line. 因此,要变通解决此问题,不要创建那么长的命令行。 If you cannot modify your bat file create other batch file that runs your unmodifirable file. 如果您无法修改bat文件,请创建另一个运行您的不可修改文件的批处理文件。 This second bat file can be created at runtime dynmically somewhere under user temp. 可以在运行时动态地在用户温度下的某个位置创建第二个bat文件。 Then you can run it and and remove when it is no longer needed. 然后,您可以运行它,并在不再需要它时将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM