.sh execution asking for "how you want to open this file" , not executing in cmd - windows

I have downloaded kafka and trying to execute the start script using
.\bin\kafka-server-start.sh
.\config\server.properties
in cmd prompt, but the script is not executing ,instead windows is throwing "How do you want to open this .sh file".
The current default in "Set Assosiations" is "unknown application", not able to figure out why it is not executed.

Kafka has seperate batch files for windows environment in <kafka dir>/bin/windows directory. Use those to run on windows environment like this.
Use kafka-server-start.bat and kafka-server-stop.bat for kafka cluster.
You can find more details. https://github.com/apache/kafka/tree/trunk/bin/windows

There are Windows versions of all the scripts in the bin/windows directory, see https://github.com/apache/kafka/tree/trunk/bin/windows.
When running on Windows, use those instead of the normal shell scripts. This is mentioned literally in the first line of the Quick Start section in the docs.

Related

TortoiseSVN Hook Scripts No Longer Run

A while a go we set up a post_commit hook script in TortoiseSVN, this is a simple batch file, and this worked fine. We are running Windows 10.
Recently (around the beginning of 2023) this stopped working. TortoiseSVN now reports:
The hook script returned an error:
The process cannot access the file because it is being used by another process.
The script executes fine when run manually.
Changing the script to execute to another batch file or a program, results in the same message.
Does anyone have any suggestions?
Thanks,
Chris
Edit:
The hook script is client side and is configured as:
Working Copy Path:
C:\Temp\Repo
Command Line To Execute:
C:\Users\chris\SVNFeeder\testrepo_sync.bat
Wait for script to finish: True
Hide the script while running: False
Always execute the script: True
The batch file contains the following:
java -jar %USERPROFILE%/SVNFeeder/SvnFeeder.jar -c %USERPROFILE%/SVNFeeder/testrepo_configFile
The java file updates our Jira server with commit messages.
Changing the command line to execute the java file directly results in the same error, even a simple batch file that only creates a folder doesn't execute.
There is nothing wrong with the batch file or the java file as both execute fine outside of TSVN.
I have just found out that Sophos was blocking the execution of the script.
There was no mention of this in the events page, which didn't help track it down.

Is there a command in Shell scripting for executing .exe file and running commands automatically inside of it? replacing the user interaction

I have a .sh script file that I'm modifying which runs an .EXE file that opens the Windows command line prompt automatically.
This .exe asks the user for an input (name of the file in the folder workspace that it will read)
I want to automate this step in my shell script so my user doesn't have to interact with this, and run the commands automatically
I read a bit about the expect command but I think that is for Linux only.
Can someone help me, I'm pretty new to Shell scripting and I couldn't find any useful information elsewhere.
I'm assuming that your executable accepts command-line arguments. So, here we go.
You can use the "start" command in Windows Shell. For example:
start C:\path\to\program.exe -argument
If you want to make the script wait until the .exe file finishes running before continuing, you can use the "/wait" command:
start /wait C:\path\to\program.exe -argument
IF all of that doesn't work, please try:
start myprogram.exe /command1 /command2 /command3
Hope it helps,

How to run zookeeper.sh file in windows

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.

Batch file is working from cmd prompt but not from IIB tool

I have wrapped a simple perl command in a simple windows batch file and executed the same from cmd prompt which worked as expected.
But if I trigger the same batch file from my message flow in IBM Integration Bus, it is unable to recognize the 'perl' command.
Provided the environment variables are set properly and the batch file is working fine from command prompt.
Can anyone please help me on this to identify the issue and resolve the same?
Thanks for the reply.
Actually the error was related to the path from where the batch is calling the perl command.
IIB was always executing it from it's runtime path and that's why it could not recognize the perl command.
The clue is to execute the batch from the path where the perl.exe is present. By following the same the issue got resolved.

Bamboo Remote Agent Does Not Recognized Windows command or exectuables

I started trial with Bamboo recently. I ran bamboo server on my personal PC and configure our build server to be a remote agent. Our build environment is in Windows. The build process is carried out via TCL script, which basically executes Windows batch command to build different stuffs. The remote agent execute that TCL script after source code checkout. However, the Windows commands that are suppoesed to execute do not actually execute. For example, if we try to execute msbuild batch command from windows, we will do
exec "cmd << msbuild **.sln"
in the TCL script. The result of this command is 'msbuild' is not recognized as an internal or external command, operable program or batch file. The problem was gone for two builds then re-appear right after.
I tried just simply called the script from CMD on the remote agent and aslo execute the job on my PC(which is the default agent) through Bamboo. The mentioned problem does not occur.
Can anyone tell me if there are some other configurations that I have missed?
Thank you.
Well, your command:
exec "cmd << msbuild **.sln"
That's not going to work (unless you have a program called exactly that, which I think is illegal on Windows; you can't have * in a file name). Instead, you need to invoke it either via cmd or using a direct Tcl style invoke.
Which one will be best? I don't know; try them and find out for yourself.
Invoking via cmd.exe
exec cmd /c msbuild *.sln
Invoking a more Tcl-ish style
exec msbuild {*}[glob *.sln]
(Note that I think ** is always unnecessary as * just means “any number of any character” when expanding a glob. If you're using it to mean “recursive search through a directory structure”, say so and I'll provide code to do it using the find command in the Tcllib fileutil package.)

Resources