为什么只有这个Windows批处理文件的第一行执行,但所有的三线在shell命令执行? [英] Why does only the first line of this Windows batch file execute but all three lines execute in a command shell?

查看:172
本文介绍了为什么只有这个Windows批处理文件的第一行执行,但所有的三线在shell命令执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有执行三个Maven的命令,一前一后的批处理文件。每个命令都可以在脚本中成功执行 - 本身!但是,当我所有三个命令添加到同一个文件,脚本退出之前,只有第一个执行。任何想法,为什么?

I have a batch file that executes three Maven commands, one after the other. Each command can be successfully executed in the script - by itself!. But when I add all three commands to the same file, only the first one executes before the script exits. Any idea why?

mvn install:install-file -DgroupId=gdata -DartifactId=base -Dversion=1.0 -Dfile=gdata-base-1.0.jar  -Dpackaging=jar -DgeneratePom=true
mvn install:install-file -DgroupId=gdata -DartifactId=blogger -Dversion=2.0 -Dfile=gdata-blogger-2.0.jar  -Dpackaging=jar -DgeneratePom=true
mvn install:install-file -DgroupId=gdata -DartifactId=blogger-meta -Dversion=2.0 -Dfile=gdata-blogger-meta-2.0.jar  -Dpackaging=jar -DgeneratePom=true

另外,如果我复制所有三个命令并将其粘贴到一个命令shell(CMD.EXE),他们执行一个其他的没有问题了。因此,这是显然有些问题用DOS批处理文件。

Also, if I copy all three commands and paste them into a command shell (cmd.exe), they execute one after the other with no problem. So this is apparently some issue with the dos batch file.

推荐答案

Maven使用批处理文件来完成其业务。对于任何批处理脚本,你必须使用 呼叫 命令,所以它知道所调用的脚本完成后,返回到你的脚本。尝试prepending 呼叫所有命令。

Maven uses batch files to do its business. With any batch script, you must call another script using the call command so it knows to return back to your script after the called script completes. Try prepending call to all commands.

另一件事你可以尝试使用 启动 命令,它应该同样工作。

Another thing you could try is using the start command which should work similarly.

这篇关于为什么只有这个Windows批处理文件的第一行执行,但所有的三线在shell命令执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆