Cygwin:如何为Windows程序传递参数?
我在 cygwin 和将参数传递给 Windows 程序时遇到一个小问题。
我对windows shell之类的知识还很少。我的一个朋友为windows编写了一个程序来进行一些计算。要启动该程序,您只需要一个控制台,然后输入类似 program.exe param1 param2 param3
的内容,一切都可以顺利运行。
我现在需要的是运行不同的参数(很多不同的参数)。为此,我考虑编写一些脚本并通过脚本调用该程序 1000 次。这就是我使用 cygwin 的原因,因为我没有任何 Windows 脚本编写经验,但有一些 Linux 和 bash 经验。我的问题是现在我不知道如何传递调用的参数。
我尝试将数组传递给命令,但这没有成功。我尝试过的:
args=("param1" "param2" "param3")
./program.exe $args
编辑
如果我执行以下操作(作为示例),它似乎可以工作:
args="param1 param2 param3"
eval "./program.exe $args"
I have a small problem with cygwin and passing parameters to a windows program.
My knowledge about windows shells and so on is pretty small. A friend of mine wrote a program for windows to do some calculations. To start the program you just need a console and you have to type something like program.exe param1 param2 param3
everything runs without any problems.
What I need now is to run for different parameters (a lot of different parameters). To do it so, I thought about scripting something and to call 1000times the program by the script. That's why I'm using cygwin because I don't have any windows scripting experience, but some experiences with Linux and bash. My problem is right now I don't know how to pass the parameters for the call.
I tried to pass an array to the command, but this didn't worked out. What I tried:
args=("param1" "param2" "param3")
./program.exe $args
EDIT
It seems to work if I do the following (as an example):
args="param1 param2 param3"
eval "./program.exe $args"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
对于 unix 样式参数,这有效:
对于 Windows 样式参数,将斜杠加倍:
Try
For unix-style arguments this works:
For Windows style arguments double the slashes: