Perl的运行命令@echo没有找到一个批处理文件 [英] Perl running a batch file @echo command not found

查看:1511
本文介绍了Perl的运行命令@echo没有找到一个批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上使用先生并允许任何后运行之前任意命令/库行动。至于我可以看到这是通过调用Perl的系统函数简单地完成。然而事情似乎很错了我的设置:当制作先生运行下面的批处理文件,位于D:

I am using mr on Windows and it allows running arbitrary commands before/after any repository action. As far as I can see this is done simply by invoking perl's system function. However something seems very wrong with my setup: when making mr run the following batch file, located in d:

@echo off
copy /Y foo.bat bar.bat

我得到最基本的Windows错误命令:

I get errors on the most basic windows commands:

d:/foo.bat: line 1: @echo: command not found
d:/foo.bat: line 2: copy: command not found

要确保先生是没有问题的,我跑的perl -e'系统(D:/foo.bat),但输出是一样的

To make sure mr isn't the problem, I ran perl -e 'system( "d:/foo.bat" )' but the output is the same.

使用XCOPY,而不是拷贝,似乎xcopy命令被发现,因为输出现在

Using xcopy instead of copy, it seems the xcopy command is found since the output is now

d:/foo.bat: line 1: @echo: command not found
Invalid number of parameters

不过,我不知道什么可能是错误的参数。我想也许这个问题是批处理文件还没有完全进入标准的命令环境,所以我尝试通过的perl -e明确运行它的系统(CMD /cd:\\foo.bat)' 但这只是开始cmd并没有运行命令(我不得不退出命令行,回到一个我在那里)。

However I have no idea what could be wrong with the parameters. I figured maybe the problem is the batch file hasn't full access to the standard command environment so I tried running it explicitly via perl -e 'system( "cmd /c d:\foo.bat" )' but that just starts cmd and does not run the command (I have to exit the command line to get back to the one where I was).

什么是错在这里?详细解释将是巨大的。此外,我该如何解决这个问题?我preFER离开该批处理文件是一个解决方案。

What is wrong here? A detailed explanation would be great. Also, how do I solve this? I prefer a solution that leaves the batch file as is.

推荐答案

回声指令由运行命令提示符实例直接执行。
但Perl是的 推出一个新的进程 的与你的命令。你需要一个cmd实例中运行你的脚本,这些命令工作。

The echo directive is executed directly by the running command-prompt instance. But perl is launching a new process with your command. You need to run your script within a cmd instance, for those commands to work.

CMD / C 必须工作。检查您是否有您所提供给它的路径中有空格。
您可以使用的传递参数​​参数化的方式,

Your cmd /c must work. Check if you have spaces in the path you are supplying to it. You can use a parametrized way of passing arguments,

@array = qw("/c", "path/to/xyz.bat");
system("cmd.exe", @array);

回声指令是的不可以的可执行文件,因此,它的错误了。
同样是的复制命令也是如此。它的不可以的可执行文件,而 XCOPY.EXE

The echo directive is not an executable and hence, it errors out. The same is true of the copy command also. It is not an executable, while xcopy.exe is.

这篇关于Perl的运行命令@echo没有找到一个批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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