linux - Executing a tcpstat command and performing operations on its output simultaneously -


i trying run tcpstat command gives output number of icmp requests being received. , @ same time need check count if exceeds threshold, message should displayed.

i tried out this

#!/usr/bin/perl  @count= system "tcpstat -i eth1 -f icmp[0]==8 -o %c";  $i=0; while ($i<1000) { print "count of packets :".$count[$i]."\n"; $i=$i+1; if($count[$i]>50) {    print "thats lot of pings"; } } 

but doesn't seem work because.. execution of command doesn't end without user interrupt...

is possible that? running command , simultaneously performing operations on output?

run tcpstat command in shell , pipe output perl script.

tcpstat -i eth1 -f icmp[0]==8 -o %c  |  perl script.pl 

in way, should expect input <stdin> , remove system call in perl, of course.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -