简体   繁体   English

如何在 Mac 终端中使用命令行参数运行 exe 文件?

[英]How to run exe file with command line arguments in Mac terminal?

I want to run the exe file with command line arguments in Mac terminal我想在 Mac 终端中运行带有命令行参数的 exe 文件

p1.exe -f input.txt

But im getting error -bash: p1: command not found但我收到错误 -bash: p1: command not found

I have converted python file p1.py into p1.exe using我已经将 python 文件 p1.py 转换为 p1.exe 使用

pyintsaller p1.py --onefile

And running the python file with arguments works并使用参数运行 python 文件

python p1.py -f input.txt

This isn't to do with Python, but is a basic command shell issue.这与 Python 无关,而是一个基本的命令外壳问题。 To run an executable from the current directory, you need to use the ./ prefix.要从当前目录运行可执行文件,您需要使用./前缀。

./p1.exe -f input.txt

Note, it's a bit odd to use a .exe extension for a Linux executable.请注意,对 Linux 可执行文件使用 .exe 扩展名有点奇怪。

Note that on Unix like systems (Linux/Unix/Solaris/MacOS).请注意,在类 Unix 系统(Linux/Unix/Solaris/MacOS)上。 scripts can be run without explicitly invoking interpreter, if two conditions are meet:如果满足两个条件,脚本可以在不显式调用解释器的情况下运行:

  • script file starts with this line (or similar): #!/usr/bin/env python脚本文件以这一行(或类似行)开头: #!/usr/bin/env python

  • file has executable attribute flag is set文件具有可执行属性标志已设置

Then you can run script like this:然后你可以像这样运行脚本:

./p1.py --onefile

./ means run thing from local directory. ./表示从本地目录运行东西。 If this is not pressent the it tries to run things located by PATH variable, that is why you can run interpreter python如果这不是紧迫的,它会尝试运行由PATH变量定位的内容,这就是您可以运行解释器python

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

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