Can I/how do I pipe each line of output from a command to another command (on Windows).
For example I have tshark which outputs:
1 0.000000 1.1.1.1 -> 1.1.1.2 TLSv1.2 85 Application Data
2 0.000726 1.1.1.2 -> 1.1.1.1 TLSv1.2 89 Application Data
3 0.064803 1.1.1.3 -> 1.1.1.2 TLSv1 155 Application Data
4 0.155403 1.1.1.1 -> 1.1.1.2 TCP 60 443â┼'62745 [ACK] Seq=32 Ack=36 Win=374 Len=0
5 0.268586 1.1.1.2 -> 1.1.1.3 TCP 54 56149â┼'443 [ACK] Seq=1 Ack=102 Win=63331 Len=0
6 0.730557 1.1.1.2 -> 1.1.1.4 UDP 45 Source port: 46586 Destination port: 52531
7 1.069927 1.1.1.5 -> 1.1.1.2 TCP 60 40020â┼'50293 [PSH, ACK] Seq=1 Ack=1 Win=136 Len=3
8 1.179893 fe00::dd00:9f00:dd00:1e00 -> ff00::c SSDP 208 M-SEARCH * HTTP/1.1
9 1.269580 1.1.1.2 -> 1.1.1.5 TCP 54 50293â┼'40020 [ACK] Seq=1 Ack=4 Win=16130 Len=0
And I want to execute my-prog.bat on each line, e.g:
my-prog.exe 1 0.000000 1.1.1.1 -> 1.1.1.2 TLSv1.2 85 Application Data
my-prog.exe 2 0.000726 1.1.1.2 -> 1.1.1.1 TLSv1.2 89 Application Data
my-prog.exe 3 0.064803 1.1.1.3 -> 1.1.1.2 TLSv1 155 Application Data
my-prog.exe 4 0.155403 1.1.1.1 -> 1.1.1.2 TCP 60 443â┼'62745 [ACK] Seq=32 Ack=36 Win=374 Len=0
my-prog.exe 5 0.268586 1.1.1.2 -> 1.1.1.3 TCP 54 56149â┼'443 [ACK] Seq=1 Ack=102 Win=63331 Len=0
my-prog.exe 6 0.730557 1.1.1.2 -> 1.1.1.4 UDP 45 Source port: 46586 Destination port: 52531
my-prog.exe 7 1.069927 1.1.1.5 -> 1.1.1.2 TCP 60 40020â┼'50293 [PSH, ACK] Seq=1 Ack=1 Win=136 Len=3
my-prog.exe 8 1.179893 fe00::dd00:9f00:dd00:1e00 -> ff00::c SSDP 208 M-SEARCH * HTTP/1.1
my-prog.exe 9 1.269580 1.1.1.2 -> 1.1.1.5 TCP 54 50293â┼'40020 [ACK] Seq=1 Ack=4 Win=16130 Len=0
My my-prog.bat is simply echo %TIME% %* >> test.txt
I tried a few things like (using GnuWin xargs):
tshark | xargs my-prog.bat
tshark | xargs -n1 my-prog.bat
But the best I got was outputing litterally %* to the file. (my-prog.bat test works as expected and appends test to the file)
(Note that tshark will continue to run until CTRL+C is pressed)
Aucun commentaire:
Enregistrer un commentaire