Cygwin:如何为Windows程序传递参数?

发布于 2024-12-05 05:19:55 字数 593 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2024-12-12 05:19:55

尝试

args="param1 param2 param3"
./program.exe $args

对于 unix 样式参数,这有效:

args="-l -t"
ls $args

对于 Windows 样式参数,将斜杠加倍:

taskkill //PID 15804

Try

args="param1 param2 param3"
./program.exe $args

For unix-style arguments this works:

args="-l -t"
ls $args

For Windows style arguments double the slashes:

taskkill //PID 15804
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文