MSYS error "rem: command not found" - windows

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

Related

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.

Why can Windows command prompt run this file?

I have a ./configure file that I'm supposed to run by putting it in the command prompt. It works when I run it in the git prompt but when I run it in the Windows command prompt it gives me:
C:\cygwin\home\doxygen\configure> configure
'configure' is not recognized as an internal or external command,
operable program or batch file.
Even though I'm in the correct directory (and running dir shows me that the file is there) it still stays that it cannot find the file. This is the same for all files that don't have an extension on them. Why does this happen and how can I get this to work?
./configure is not a program. It's more of a shell script usually. My analogy may not be good but consider it to be the equivalent of windows batch files (in this case you can say it's a .sh without the extension).
It will only run from a cygwin/unix shell.

Does Windows 7 hide files from Ruby?

I am trying to run the program nbtstat.exe(located in c:\windows\system32) from a ruby script. The problem is that it appears that Windows 7(64-bit) is hiding the program from the ruby script(it works fine in Vista).
For example,
Nbtstat command: "nbtstat"
Dir command: dir "C:\Windows\System32\n*.exe"
If I run the nbtstat command in just the command line, nbtstat will run fine. If I then run the dir command, nbtstat.exe will show up in the list of files in that directory.
However, if I run the nbtstat command from the ruby script(using backticks, system, %x or Kernel.open), it will not succeed. If I then run the dir command(also from the ruby script), it will show a list of files in the directory minus nbtstat.exe and a few others.
UAC is turned off and it is being ran from an administrator. I tried this in both ruby 1.8.6 and 1.9.2.
I created a .bat file that runs the nbtstat command and it worked fine but if I call the .bat file from the ruby script it will fail.
Any ideas?
Thank you.
On Win64, if you run a 32-bit process, Windows will remap the c:\windows\system32 directory to actually point to c:\windows\syswow64. That directory doesn't contain the binary you're looking for, so your 32-bit process doesn't see it.
You can detect whether that's the case by looking at the process's environment (look at the output of "set" for the env variables), although I don't know of a way to make the process see the actual 64-bit directory.
Maybe the shell in which your ruby script is launched was created before the PATH is initialized. I noticed this issue in Windows 7. You can try to print PATH in your script to verify if you are encountering this issue.

run windows command from bash with output to standard out?

Folks, I'm using git tools such as git bisect run which need to call a command to build and test my project. My command to do is nant which is a windows program. Or a build.cmd script which calls nant.
It's easy to get the bash to call the nant build to run.
But the hard part is how to get the standard output written to a file?
I even installed the Windows PowerShell to try running a command from bash.
Again, it works but the standard output fill says "permission denied" when
I try to read it while the build is going on.
Update:
When running nant, the entire path is used. It is installed and runs fine. The problem is how to get the standard output when running from bash.
If running nant from the windows prompt with "> build.out" at the end of the line, you will get the standard out. But the same never works under bash. It just says build.out is locked, permissions denied.
Update:
Using tee as suggested below also doesn't solve the problem. In that case the file still report "access is denied" with any attempts to read it while the build runs. But also, the tee program never writes anything to standard output.
(If I am understanding your question correctly...)
You can probably use the 'tee' command to split the output to both a file and stdout. The line echo I am building something | tee build.out will both print the output on the console and save it to the file named "build.out".
The tee command is usually available in Cygwin, and also apparently in the Bash shell installed by msysgit (where I just tested it). Here's a good reference page for more details.
Okay, finally resolved this. It turns out the the nant build script was using git feature to erase all ignored files to cleanup. That was deleting the build.out file can causing these strange issues. Now, the process writes the build.out file to a parent directory so that it won't get deleted and now everything works smoothly as expected.

Resources