简体   繁体   中英

How to run an executable on Cygwin

Say I want to run an executable with a filename argument that is within my working directory, in Windows cmd I would go:

C:\Python27\python signalme.py

How can I do so in Cygwin? NOTE: C:\\Python27\\python is an executable. Please give me a full answer, I read somewhere here that you should add a .\\a , but I couldn't know where to add it.

Cygwin attempts to make a Linux-like user environment available on Windows. To run a executable file on a Linux-like command line, you need the following things:

  1. You have to be able to find the executable, which means one of the following:
    • The executable is in a directory that is included in your PATH environment variable.
    • You know the explicit absolute path to the executable, which you can specify at the command line
    • You know the relative path from the current directory to the executable, which you can specify at the command line.
  2. The file has to have the executable permission set for the user you're attempting to use to run that file.

So, to run an executable in your working directory, you can specify the relative path to the working directory, along with the filename: ./foo.exe .

In your case, you want to use the Python interpreter to run a local Python file. You will most likely need to use the Cygwin-installed Python. That Python will probably be in your PATH, so just run:

python signalme.py

This could fail, with an error message like bash: python: command not found - in which case you should re-run your Cygwin setup, look for the opportunity to install Python, and make sure you install it.

/cygdrive/c/python27/python.exe signalme.py

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