0

For some reason I need to run a (hopefully simple) sh file under Windows and be able to do so from another application. I can do that using cygwin, but for various reasons I need this operation to be easy to reproduce on another machine (installing cygwin on another machine is out of question).

The first logical step was to copy sh.exe to another location and try running it in Windows cmd. I got a few "missing library" errors, but after copying:

  • cyggcc_s-1.dll
  • cygreadline7.dll
  • cygncursesw-10.dll
  • cygiconv-2.dll
  • cygintl-8.dll
  • cygwin1.dll

I can run sh.exe in cmd.

I tried running the sh file with this copy of sh.exe, but now I get an error that gawk is missing. I tried to copy gawk.exe (and necessary libraries) to the same folder, but sh.exe can't see it (I also tried copying gawk-4.1.1.exe, but the result was the same).

I suspect sh.exe looks for some environment variable which would then point to the location of dependencies (such as gawk.exe), but I'm not sure what environment variable it is and if sh.exe respect plain windows environment variables.

So my question is, can I run sh.exe under Windows cmd (and eventually directly in windows) and if yes, then how do I go around the problem described above?

1

While writing this question a few ideas popped into my head and one of them was "If there is an environment variable that is missing, surely cygwin is setting it when I start it.".

I did a text search for cygwin\bin and cygwin/bin in the cygwin folder and the second one pointed me to .bashrc file. Turns out the path required by sh.exe was stored in plain old PATH environment variable.

In short, if I execute:

SET PATH=%PATH%;.

in the cmd, I can then run sh.exe with the dependables placed in the same folder (it's likely I might need to replace . with some specific path later on, but it's good enough for now). Later on I'll probably have to move this to a batch file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.