I want to create a batch file thats start cygwin and executes a specific command (The command is to read a bash file and executes some command inside it).
This is the batch file that I have developed, it works to some extent. the cygwin terminal opens and tries to read the bash file, but cannot execute the commands inside:
@ECHO OFF
C:\cygwin64\bin\mintty.exe -li /cygdrive/c/(path-to-bash-file-location)/(MyBashFile)
PAUSE
How can I make this work?
From your batch file, launch Cygwin's bash shell and use the login flag. This provides a foundation for setting path and environment variables through your .bash_profile
or .bashrc
files. I believe this may be the source of your difficulties.
@ echo off
C:\cygwin64\bin\bash --login -c "cd ~/path/to/desired; ./mybashfile.sh"
If you provide more details about the nature of your bash file, I can be more specific. Good luck.