Running a bash shell script on Windows from within in Notepad++ using NppExec (and Cygwin)

Validatorian picture Validatorian · Jun 27, 2012 · Viewed 13.3k times · Source

I'm trying to reconstruct how to execute a bash shell .sh file on my Windows machine from within Notepad++ using NPPExec. (I've done this successfully before, but my HDD crashed and I don't recall how I did it previously.)

When it was working before, I would run the NPPExec script that called a .sh file, and it showed me the console output of the .sh file processing in Notepad++ as if it were processing in cygwin.

This is the example .sh file that I'm trying to get to work:

message="Testing"
echo $message

This file is located in the root of C:.

Failed Attempts:

None of the following three methods work:

  • Execute: C:\nppexec.sh

Response:

CreateProcess() failed with error code 193:
%1 is not a valid Win32 application.
  • Execute: npp_exec C:\nppexec.sh

Response:

message="Testing"
CreateProcess() failed with error code 2:
The system cannot find the file specified.    
$message
  • Adding #! /bin/bash to the .sh file as the first line just causes an additional error when npp_exec is run:

    NPP_EXEC: C:\nppexec.sh
    #! /bin/bash
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.
    

Answer

Validatorian picture Validatorian · Jun 28, 2012

The solution was to call bash directly:

C:\cygwin\bin\bash --login -c "command.sh"