views:

67

answers:

1

Hi,

I have a Linux .bsh script, which I need to run on a Windows 7, and I’m having some difficulties with creating the script. I would like a script so I can run it in my cmd in windows or if the script could output to a file.

The .bsh script looks as following:

for ((r=0; r <$[0]; r++))

    netcat localhost 4444 < $[1] $
done

wait

I’ve two parameters in the .bsh script $[0] and $[1] and if possible I would like to keep them. The other important thing is the “$” in the end of the netcat script. This is, in Linux, to spawn a process / thread and it is important that I can do this because I’ve some test I need to run with and without it and compare it.

The last thing is, that when I’m running the .bsh script on Linux, I use following command before the filename: TIME so I can get the time for running the script. If that is possible, as an output to a file or the console, that would really help me.

If you need any other information, please do ask.

Sincerely

Mestika

+1  A: 

Unfortunately, the Windows commandline is nowhere near as powerful as the BASH shell; don't expect to achieve the same thing in a Windows *.bat script as you do in a BASH shell script, without lots of pain and headaches. For this situation, I have two suggestions: either download and install Cygwin, and simply use the original shell script with Cygwin's copy of BASH, or reimplement the script using Python, which is far more expressive than the Windows commandline and yet is incredibly portable. Also, I would add that you are missing a "do" in your script. Are you sure your script works on UNIX?

Michael Aaron Safyan
I'd add powershell to this, it should easily be able to perform a loop and run netcat
nos
@nos, perhaps, but who the hell knows how to use it? There are far more tutorials, manuals, forums, articles, and help pages out there for BASH then there are for Power Shell. Also, BASH is an implementation (albeit with many extensions) of the UNIX shell (/bin/sh), which is mandated by the Single UNIX Specification. So, in short, BASH has more support and is also standards based.
Michael Aaron Safyan
You'll note that the OP tagged the question with "wsh" and "vbs" rather than "cmd". Also, @Michael, PowerShell is well-known, well understood and well supported.
Dennis Williamson