-1

我想使用 CMD 命令或批处理脚本更新具有所有 RTP 范围的wireshark decode-as 文件。

该文件必须包含如下值:

decode_as_entry: udp.port,16384,(none),RTP
decode_as_entry: udp.port,16386,(none),RTP
decode_as_entry: udp.port,16388,(none),RTP
.
.
.
decode_as_entry: udp.port,32766,(none),RTP

如您所见,手动为所有 RTP 范围添加行很麻烦。

所以批处理脚本必须创建一个文本文件,并将这些行一一添加,直到32766达到值。

我理解代码的逻辑,它应该包含一个FOR循环(用于迭代)和一个IF语句(打破循环直到32766达到),但由于我缺乏知识,我无法成功构建批处理文件。

4

1 回答 1

0

Compo 使用FOR /L作品的评论。从 cmd.exe .bat 文件脚本中使用 PowerShell 的另一种方法是:

powershell.exe -NoLogo -NoProfile -Command ^
    "(16384..32766).Where({$_ %% 2 -eq 0}) |" ^
    "    ForEach-Object { """decode_as_entry: udp.port,$($_.ToString()),(none),RTP""" } |" ^
    "    Out-File -FilePath '.\test.txt' -Encoding ASCII"

当然,如果您可以运行 PowerShell 控制台或 .ps1 脚本文件,那就更容易了。

(16384..32766).Where({$_ % 2 -eq 0}) |
    ForEach-Object { "decode_as_entry: udp.port,$($_.ToString()),(none),RTP" } |
    Out-File -FilePath '.\test.txt' -Encoding ASCII
于 2020-12-18T15:37:16.923 回答