简体   繁体   中英

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. 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 .

Note the extension, .ovpl , which isn't registered as an executable. 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. 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 .

When you do this, Windows doesn't do anything with the arguments beyond the first. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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