I have Cygwin and its bin path is in the path variable. My .sh file association is set to bash.exe. However, when I try to execute a shell script from a Jenkins build, I get the following error:
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh"
Other posts have indicated this could be an issue with the .sh file association, but I don't see why that would be the case when I'm able to execute .sh files just fine outside of Jenkins. Can anyone tell me if I'm missing a step here? Thanks in advance.
hmm... running jenkins on windows and using cygwin doesn't sound good. are you sure that the command sh is available in your environment? maybe try sh.exe that might work. otherwise start cygwin with bash.exe and try to set an the alias sh to sh.exe... something like that
Related
I am following this tutorial where i have to run this command in order to start the zookeeper server.
./bin/zookeeper-server-start.sh config/zookeeper.properties
But the problem is this command is not working properly. I found that .sh file is bash file that required cygwin. I have installed it and then run command like this
C:\cygwin64\bin\bash.exe ./bin/zookeeper-server-start.sh config/zookeeper.properties
But it is showing:
I can confirm that in bin directory the file is exsits. what i am doing wrong?
Here is my directory snapshot from where i running the command:
Note: I have successfully tested bin/windows zookeeper bat file but i want to run it through .sh file as the kafka security tutorial which i am following using this.
From your screenshot, I conclude that you are using Cygwin. So, please add the cygwin tag to your question.
As you can see from the error message, the command dirname is not found by bash, so assuming that your Cygwin installation is not broken, I assume that the PATH is not set correctly; in your setup, dirname.exe should be in C:/cygwin64/bin (please verify this).
Your usage of bash.exe is a bit unusual in that you run it directly from a Windows cmd prompt. The more common way would be to use it from the 'Cygwin Terminal', which you get created a Windows-link to, when installing Cygwin, or to use another suitable Terminal program; I'm using for instance mintty for this task (also available via the Cygwin installer).
Having said this, it is possible to run bash.exe in the way you are doing it, but you then have to ensure, that at least the PATH is set up correctly. One possibility to do this, is to add C:\cygwin64\bin to your Windows PATH, but this has the drawback, that some commands have the same name in the Windows world and in Cygwin, though they serve a completely different purpose, and this will bite you sooner or later. Another problem is that at some point, you will rely on other bash specific setups besides the PATH.
A better way to accomplish your goal is IMO to ensure, that the system wide bash-initialization files are sourced by bash. If I have to run the script from a Windows cmd prompt, I would run it by
C:\cygwin64\bin\bash.exe --login YOURSCRIPT
This will read the file (in your setup) C:\cygwin64\etc\profile before running YOURSCRIPT, so you can check, that the PATH is correctly set there, by looking at this file. In a default installation, this should be the case.
After having read this file, it will try to read the file .bash_profile in your Cygwin HOME directory, so if you need additional settings for your (non-interactive) bash-scripts, create this file and put your settings there.
I'm trying to run a mocha test for my node.js code which runs the following line:
exec(`sh ${scriptFile}`);
When I run it from the command line (Git Bash) using npm test, it passes. However, when I run it from WebStorm I get the following error:
'sh' is not recognized as an internal or external command,
operable program or batch file.
I feel like I'm probably missing some WebStorm setting, but I can't figure out what it is. Any ideas?
P.S. I'm on Windows.
For those who are using phpStorm on Windows and come here by Google
Install Git on your machine. Go to Settings/Terminal and set shell path to C:\Program Files\Git\bin\sh.exe
Also add C:\Program Files\Git\bin to your PATH in environment variables.
Git Bash implements a *nix-esque shell simulating bash which can parse your command. Webstorm appears to be trying to execute your command in either powershell or cmd, which do not support sh syntax.
Open the Terminal page of the Settings/Preferences dialog, and configure the Shell path field as follows:
"[path to the git installation]\bin\sh.exe" -login -i
This will probably be "C:\Program Files\Git\bin\sh.exe" -login -i
Source: https://www.jetbrains.com/help/webstorm/2017.1/working-with-embedded-local-terminal.html
I have setup a jenkins server on windows10 pro and installed ubuntu bash on the system. And I created a Executable windows batch command and put the command bash -c ls there. When executing this job I got below error:
c:\jenkins\workspaces>bash -c ls
'bash' is not recognized as an internal or external command,
operable program or batch file.
It says that bash is not recognized as an internal or external command. Then I tried to use the absolute path but still not work. The error is shown as below:
c:\jenkins\workspaces>C:\Windows\System32\bash.exe -c ls
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command,
operable program or batch file.
I can run the command manually on windows. How can I configure this on jenkins? I need to run the build command from windows normal command window and in my build script it needs to launch a process inside bash.
You could install MsysGit, which includes bash, and in Jenkins you have to set the shell executable, which is the path to the sh.exe
You could also install cygwin, but i think this uses high amount of RAM for just running bash scripts.
similiar to what #Borislav said, a migrated shell might help, if you had mingw or msys2 and start your java -jar slave.jar from that bash console, you should be able to directly chose to execute shell, just considering it to be a linux node at your jenkins
Try to install git. Git hold a minimal bash environment which can help in your case.
https://git-scm.com/
I am running a command do shell script on Apple Script Editor and I wan to save and run it as a application but while i am executing it ,I am getting a message Permission Denied..? Tell me how to resolve it. All this I am doing on MacOsx
the command is:
do shell script "xxx.jar"
and this command was running fine while I am running it as a script.
You need to have the executable bit set on the script:
chmod +x /path/to/your/script
A .jar file is not a shell script; If you are trying to run the classes within the .jar file, then this will work provided the manifest is correctly configured within the .jar file:
do shell script "/usr/bin/java -jar xxx.jar"
I am getting this error "rem:command not found" in my batch file. Other dos commands (e.g. echo) are also not found.
My makefile is calling this batch file. This works previously when I am using cygwin. But when I changed to MSYS, I am getting this error. Anyone know why this is?
I am using MSYS version 1.0.17 on a Windows pc. But, I did not install Mingw. Should i install it also?
It looks as though you are trying to run a "Batch" file using Bash. This will not work. While Batch file interprets rem as a comment, Bash simply thinks it is a command and tries to run it.
My suggest would be to rewrite it as a Bash script, perhaps this could be a starting point.
After trying with cmd //c [path_to_bat file] it works for me.
This is because mingw cannot run *.bat file directly after running *.bat file with cmd it works.
I found following mail thread about this type of issue
https://lists.gnu.org/archive/html/help-gnu-emacs/2003-10/msg00323.html