将Shell脚本转换为Sipp的批处理
这是用于记录sipp输出的shell脚本,如网站将Shell脚本转换为Sipp的批处理,shell,batch-file,sip,Shell,Batch File,Sip,这是用于记录sipp输出的shell脚本,如网站http://sipp.sourceforge.net/doc/faq.html 我以前从未做过批处理脚本编写,我很难理解如何转换这些代码使其在windows中运行 cat run.sh #!/bin/sh >results.txt for i in $* do echo Launching test $i >> results.txt ./sipp -sf $i -m 1 127.0.0.1 if test $?
http://sipp.sourceforge.net/doc/faq.html
我以前从未做过批处理脚本编写,我很难理解如何转换这些代码使其在windows中运行
cat run.sh
#!/bin/sh
>results.txt
for i in $*
do
echo Launching test $i >> results.txt
./sipp -sf $i -m 1 127.0.0.1
if test $? -ne 0
then
echo Test $i failed >> results.txt
else
echo Test $i succeeded >> results.txt
fi
done
exit 0
有人能帮我吗?另外,for循环中的$*
表示什么?
我在批处理中尝试了if条件的等价项
if%test NEQ 0
,但出现语法错误。$*
将所有输入参数作为一个单词返回给您
而且,据我所知,BAT中不存在“测试”。如果要检查退出代码,可以使用类似于ERRORLEVEL
(检查类似问题)的方法
您要做的是,了解shell脚本逻辑,然后使用引用站点,例如,创建代码的端口(同时请记住,它可能不是纯一对一端口)
此外,还有几点想法:
- 不确定是否有SIPP的Windows端口可用。我想检查一下李>
- 考虑开始使用Powershell。当然,它比蝙蝠多才多艺;如果你有bash的背景,可能更容易切换到
@echo off
setlocal enableextensions
for %%i in (%*) do (
echo Launching test %%i >> results.tx
.\sipp -sf %%i -m 1 127.0.0.1
if errorlevel 1 (
echo Test %%i failed >> results.txt
) else (
echo Test %%i failed >> results.txt
)
)
exit /b 0
不确定它是否适合sipp,我从未使用过它,但这是一个基本想法在输入答案之前,我可能应该先输入注释-但是如果您能够确切指定您遇到的问题以及您尝试过的内容,您可能会得到更好的帮助。