Search code examples
windowsbashbatch-filecygwin

how to write a batch (windows) to start Cygwin (mintty.exe) and then execute a python script?


Pretty much as titled. If I were to manually do this, I would first open a Cygwin Terminal (which should be /cygwin/bin/mintty.exe), and then in that terminal, cd to the directory that has the python script, and then execute the python script by doing "python myPython.py". I'm wondering if I can write a batch script or a bash script to do this: start a Cygwin Terminal, cd to a directory, execute a python script in the directory. Thanks.

Edited: So I have a python script that generates csv files for activities through mongodb.This script won't function if I run it through windows cmd. I have to run it in cygwin terminal (mintty.exe). So any alternatives to execute the python script won't work. I have to somehow start a Cygwin Terminal and execute the python script through there. Any ideas please? Thanks.


Solution

  • Depending of your needs it could be better to start mintty (creating a new window) instead of starting bash inside the cmd.exe window.

    When you want to use ansi escape sequences then it works better with a real mintty window, as the cmd window ignores the escape sequences for window resizing and positioning.

    start "" C:\cygwin\bin\mintty --exec ./myProgramToExecute.sh