14

I wrote a simple CURL and put it in a script file.

if i run mintty first and then "test.sh" it runs the script in the file just fine. Works perfectly.

however, if i try to run mintty with any of the following command line, it will not run. I'm running these in CMD

C:\>c:\cygwin\bin\mintty.exe --exec '/cygdrive/c/cygwin/bin/test.sh'

C:\>c:\cygwin\bin\mintty.exe --exec '/bin/test.sh'

C:\>c:\cygwin\bin\mintty.exe --exec '/test.sh'

C:\>c:\cygwin\bin\mintty.exe --exec 'test.sh'

C:\>c:\cygwin\bin\mintty.exe --exec 'c:/test.sh'

C:\>c:\cygwin\bin\mintty.exe --exec 'c:\test.sh'
nkman
  • 545
  • 2
  • 5
  • 13
  • C:\cygwin\bin\mintty.exe /bin/bash -l the line above works fine, but with "-e '/cygdrive/c/cygwin/bin/test.sh'" the consolewindow opens for 1 sec, then it will close. – layornos Sep 12 '13 at 12:18

4 Answers4

11

For whoever is interested in this... here is the solution

Create a shortcut in windows for mintty with the following target

Assuming your shell file is located in c:\cygwin\bin

C:\cygwin\bin\mintty.exe /bin/bash -l -e '/cygdrive/c/cygwin/bin/test.sh'
hobs
  • 18,473
  • 10
  • 83
  • 106
nkman
  • 545
  • 2
  • 5
  • 13
2

Try running bash.exe directly (or some other shell that installed with cygwin).

From a windows shell, change directory to your cygwin install and run this:

C:\cygwin\bin>bash.exe /cygdrive/c/cygwin/bin/test.sh

To get the shell script to run by double clicking a shortcut

1) Put the command in a .bat file

test.bat
---------------------------------------------------------------------
c:\cygwin\bin\bash.exe /cygdrive/c/cygwin/bin/test.sh

---------------------------------------------------------------------

2) Create a shortcut using test.bat as the target.

I tried making a shortcut with bash.exe and the command as a target. That errors out for some reason. However, wrapping the command in a .bat file works. Go figure.

2

I also use the solution offered by nkman, but I add the '-h always' option so that the console remains opened until I hit enter, to see what happened. So this is the target of my shortcut:

C:\cygwin\bin\mintty.exe -h always /bin/bash -l -e '/cygdrive/c/cygwin/home/Administrator/startup.sh'
shmocs
  • 21
  • 2
1

Best solution in my opinion:

Invokes the right shell, no unnecessary windows and invokes a bash script afterwards which will be hold.

  • Create a Shortcut to mintty.exe on your desktop, for example

  • Edit properties of the shortcut and change the target (keep the path):

  • C:\Program Files\Git\usr\bin\mintty.exe" -h always /bin/bash -l -e 'D:\folder\script.sh'

Hannes Schneidermayer
  • 4,729
  • 2
  • 28
  • 32