简体   繁体   English

为什么传递给Perl脚本的参数无法从批处理文件中运行?

[英]Why is an argument passed to a Perl script not working on running it from within a batch file?

I wrote a batch called pippo.bat for launching a program with an argument. 我编写了一个名为pippo.bat的批处理,用于启动带有参数的程序。 However, it fails in getting such argument. 但是,它没有得到这样的论点。 In other words, it acts as I don't give it any argument. 换句话说,它的作用就像我不给任何参数一样。

pippo.bat 蝙蝠

@echo off
mode con: cols=150 lines=5000
title Link Setting
echo.
echo                         LINK SETTING
echo.
cd /d E:\Program Files (x86)\pippo\bin
pippoedit.ovpl –f C:\Work\pippo.xml
pause

What's wrong? 怎么了?

You're executing pippoedit.ovpl –f C:\\Work\\pippo.xml . 您正在执行pippoedit.ovpl –f C:\\Work\\pippo.xml

Note the extension, .ovpl , which isn't registered as an executable. 注意扩展名.ovpl ,它没有注册为可执行文件。 This means you let the OS figure out and start the application associated with that extension, and start that program with that filename as argument. 这意味着您要让OS确定并启动与该扩展名关联的应用程序,并以该文件名作为参数启动该程序。 Here, a small repro: 在这里,一个小复制:

@echo off
foo.txt bar.txt

This starts Notepad or whichever application is associated with the .txt extension and displays the file foo.txt . 这将启动记事本或与.txt扩展名关联的任何应用程序,并显示文件foo.txt

When you do this, Windows doesn't do anything with the arguments beyond the first. 当您执行此操作时,Windows不会对第一个参数以外的内容执行任何操作。 Instead you should start the application directly, and pass it the arguments: 相反,您应该直接启动该应用程序,并向其传递参数:

pippoedit.exe pippoedit.ovpl –f C:\Work\pippo.xml

Or whatever the executable is called. 或任何可执行文件称为。

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

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