Miffy
Miffy

Reputation: 185

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

p1.exe -f input.txt

But im getting error -bash: p1: command not found

I have converted python file p1.py into p1.exe using

pyintsaller p1.py --onefile

And running the python file with arguments works

python p1.py -f input.txt

Upvotes: 2

Views: 5073

Answers (2)

Marek R
Marek R

Reputation: 37717

Note that on Unix like systems (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

  • 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

Upvotes: 0

Daniel Roseman
Daniel Roseman

Reputation: 599610

This isn't to do with Python, but is a basic command shell issue. 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.

Upvotes: 1

Related Questions