2

The .sh script is tested and working in cygwin, but now I want to Windows to automatically run it each hour.

The file has executable permissions and now I run it like this inside the cygwin terminal:

cd c:/users/me/documents/myfile.sh
./myfile.sh

How should I do this?

Thanks!

karhu
  • 119
  • 1
  • 9
  • possible duplicate of [How do you run a crontab in Cygwin on Windows?](http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows) – Daniel Haley Mar 05 '13 at 08:19

2 Answers2

1

Or execute bash via a batch

execute:

     call "batch_from_below.bat  "c:\user\me\documents\myfile.sh" "parameter 1, if need" "parameter 2 ..."

batch:

     @echo off
     set _CYGBIN=change-this-to-your-path-cygwin\bin

     if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%"

     REM ------------------------------------------------------------------------
     REM SCRIPT
     REM ------------------------------------------------------------------------
     set x=%1
     set x=%x:\=\\%
     set _CYGPATH_SCRIPT=%_CYGBIN%\cygpath.exe %1
     FOR /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%x%"') do set _SCRIPT=%%A

     REM ------------------------------------------------------------------------
     REM PATH
     REM ------------------------------------------------------------------------
     set _SCRIPT_PATH=%~dp1
     FOR /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%_SCRIPT_PATH%"') do set          _PATH_TO_SCRIPT=%%A

     REM ------------------------------------------------------------------------
     REM EXECUTE
     REM ------------------------------------------------------------------------
     %_CYGBIN%\bash.exe --login -c 'cd %_PATH_TO_SCRIPT%;%_SCRIPT% %2 %3 %4 %5 %6 %7 %8 %9'
inselberg
  • 549
  • 3
  • 13
  • 27
0

You need to modify the System environment variable PATHEXT to also contain .SH; as a known program file extension, then associate Bash shell files with .SH in Windows (Google will be a better friend that I am with that :).

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29