Convert simple line of batch file to bash - bash

To run the program zandronum.exe with the file brutalv21.pk3, the instructions for windows give this piece of batch file code:
#echo off
start zandronum.exe -file brutalv21.pk3
But I downloaded zandronum for Linux. What is the equivalent in Bash?

The syntax is simple:
./filename -Arguments
So, you have to write:
./zandronum -file brutalv21.pk3

windows programs won't just run under linux you'll need wine to run them. as far as I've heard ubuntu made running windows programs with wine pretty seamless

Related

why command are not recognized by the command prompt?

I have tried several times to type the command 'ls' at the command prompt of Windows 10 but it shows me that the command is not recognized as an internal or external command, an executable program or a batch file.
The "is" command is for Linux, not for Windows, and like Kraigolas said, the Windows OS command is "dir". Hope this helped.
The ls command is for linux and it's equivalent for windows command prompt is dir. But if you are more of a linux user then you can try using power-shell on windows where ls command works just like the way it works in linux. Power-shell is like a hybrid between windows command prompt and linux terminal.

Universal copy command for Windows and Linux

I was just curious that is there any universal command to copy files. Which should work for both Windows and Linux system.
I know Windows uses copy command and Linux uses cp command. But is there any universal command to do so.
If powershell is installed in your Windows OS,
then you can use the built-in command cp as well, just like Linux does.
UNIX/Linux, Mac, and Windows can all run PowerShell Core 6. https://github.com/powershell/powershell
The command is Copy-Item, but there are three (3) aliases. Using an alias at a command prompt is fine, but they should not be put into script files.
>Get-Alias -Definition Copy-Item
CommandType Name
----------- ----
Alias copy -> Copy-Item
Alias cp -> Copy-Item
Alias cpi -> Copy-Item
Since there is no "universal" command, something will need to be installed on every machine except those that already have the command you choose to make "universal." At a minimum, it would be a .bat/.cmd script on Windows or a shell script on UNIX/Linux/Mac. Choosing to implement it in Python or any other language would require that language to be installed.
There is no universal command to do this, but you have several workarounds:
use cygwin or msys on Windows to have the Linux equivalent commands on windows
use Windows Powershell (partially compatible, but works for cp)
provided that your environments all have python installed, write a python script that does what you want .

Run Cygwin script on shutdown or startup

I'm extremely new to Cygwin but I am somewhat comfortable in Linux (I can read man files fine).
I want to create a BASH script using Cygwin that deletes the files in a folder on the shutdown signal given by Windows. If this can't be done, I also could try deleting the files in the same folder on startup. I installed CRON but does CRON only works for scheduled tasks, rather than on 'signals'? Answers would be nice but a general idea of how to proceed would be even better!
I can write the script. I just don't know exactly how Cywgin interacts with the Windows OS in order to perform these procedures.
Another question, how do I run CRON on Windows startup?
If it matters, my O.S. is Windows 10 x64 running Cygwin.
Cygwin.bat, a batch file which was installed under cygwin installation folder will give you hint of how to run cygwin script.
The script contains just:
C:
chdir C:\cygwin64\bin
bash --login -i
to run the bash shell interactive.
Make a copy of Cygwin.bat with another name (Startup ?) and change last line in
bash --login path_to_your_script_here
Put the bat file or a link to in in the Startup folder.
Great thread over here: https://serverfault.com/questions/245945/autostart-cygwin-on-windows-boot-and-run-a-cygwin-command
tl;dr
you can put command directly:
#echo off
C:
chdir C:\cygwin64\bin
bash -c "/usr/bin/whatever"

How do I run a .sh script in Eclipse on Windows?

On Linux, it was pretty easy. I just did
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(shell location);
p.destroy();
But how do I do this in windows which doesn't natively allow .sh scripts? I can get the script to run using Cygwin. Is there a way I can somehow use Cygwin within Eclipse to run the script?
perhaps try adding the cygwin bin directory to your system PATH and then launch the sh.exe with the script as an argument.
Launching sh.exe (Cygwin, MinGW, or whatever) with the script as the argument is probably the best solution.
Another solution might be to update your folder options so that files with a .sh suffix are opened with sh.exe.

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.

Resources