networking - Get some information from netstat -e in new batch file -


hy, want create batch file display user information downloaded packages , uploaded packages. info can command 'netstat -e' , can save info in log file using 'netstat -e >log.txt'. want, when opening new batch file, user can see info downloaded , uploaded packages, not info command, this:

downloaded packages: -info netstat -e-

uploaded packages: -info netstat -e-

are it's impossible cut info log file , put batch file when user open batch? whole process, after opening batch file, this: -save log file 'netstat -e >log.txt', -getting needed information, -put info in batch file, -now user see information.

methods can anything, using cmd , vbs or other.

just pipe result of netstat through find command this

netstat -e | find "bytes" 

you can still redirect textfile this

netstat -e | find "bytes" > text.txt 

edit: based on comment here more possibilities

no need separate program. can pipe 2 values comment test or batchfile this. /f text in parantheses between '' executes command , lets parse result. tokens=2,3 skips first result (bytes) , puts 2 others in separate var

for /f "tokens=2,3" %a in ('netstat -e ^| find "bytes"') echo received:%a sent:%b>log.txt 

this gives in log.txt

received:74546759 sent:8593498 

or can set value environment variables , use in batch like

for /f "tokens=2,3" %a in ('netstat -e ^| find "bytes"') set received=%a&set sent=%b 

set gives then

.. received=75230393 sent=8966725 .. 

or can send values parameter batch this

for /f "tokens=2,3" %a in ('netstat -e ^| find "bytes"') mybatch %a %b 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -