帮助将 Linux .bsh 脚本转换为 Windows 的 vbs / wsh 脚本(或其他脚本)

发布于 2024-09-01 01:44:37 字数 586 浏览 3 评论 0原文

我有一个 Linux .bsh 脚本,需要在 Windows 7 上运行,但在创建该脚本时遇到了一些困难。我想要一个脚本,这样我就可以在 Windows 的 cmd 中运行它,或者脚本是否可以输出到文件。

.bsh 脚本如下所示:

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

    netcat localhost 4444 < $[1] $
done

wait

我在 .bsh 脚本中有两个参数 $[0]$[1] ,如果可能的话我想保留它们。另一个重要的事情是 netcat 脚本末尾的 “$”。在 Linux 中,这是为了生成一个进程/线程,我能做到这一点很重要,因为我有一些测试需要在使用和不使用它的情况下运行并进行比较。

最后一件事是,当我在 Linux 上运行 .bsh 脚本时,我在文件名之前使用以下命令: TIME 这样我就可以获得运行脚本的时间。如果可能的话,作为文件或控制台的输出,那对我真的很有帮助。

如果您需要任何其他信息,请询问。

诚挚的

梅斯蒂卡

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2024-09-08 01:44:37

不幸的是,Windows 命令行远不如 BASH shell 强大。不要指望在 Windows *.bat 脚本中实现与 BASH shell 脚本中相同的效果,而不会带来很多痛苦和头痛。对于这种情况,我有两个建议:要么下载并安装 Cygwin,然后简单地使用原始 shell 脚本和 Cygwin 的 BASH 副本,要么使用 Python 重新实现脚本,Python 比 Windows 命令行更具表现力,而且非常可移植。另外,我想补充一点,您的脚本中缺少“do”。您确定您的脚本可以在 UNIX 上运行吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文