- Posts: 154
- Thank you received: 0
hi all need a lil help with batch files
18 years 4 months ago #15542
by Starfire
Replied by Starfire on topic Re: hi all need a lil help with batch files
Also, if you need to do any further text pre-processing on the netsat output before you place it into the text file you can use windows versions of handy unix tools like 'grep32' .(shareware/freeware?)
For instance, if there are only certain parts of the netstat output you are interested in, you can work out the grep switches to only look for that line in the output and just send that to the text file without all the unwanted stuff.
ie. netstat -e | grep32 "Bytes"
(notice the 'pipe' = '|' the vertical bar key on all keyboards)
Produces this output only
Bytes 28941198 15506957
You can then send that output to your text file...
ie. netstat -e | grep32 "Bytes" >> text.txt
You can either have an icon setup to point to the text.txt file or have your program upload it's data from that file... whatever it is you are doing.
Just make sure where you place the grep, awk, sed, etc is in the path statement for the dos window or that you run your netstats from the directory they are located.
Unix has some very powerful text processing commands and the windows versions of them can be just as powerfull if harnessed properly.
For a deeper explanation on the power of grep see - pegasus.rutgers.edu/~elflord/unix/grep.html
Windows/Dos versions of these great Unix commands (grep/awk/sed/perl) can be found here - www.ibiblio.org/pub/micro/pc-stuff/freedos/gnuish/
They take a bit of getting used to but the rewards are worth it.
For instance, if there are only certain parts of the netstat output you are interested in, you can work out the grep switches to only look for that line in the output and just send that to the text file without all the unwanted stuff.
ie. netstat -e | grep32 "Bytes"
(notice the 'pipe' = '|' the vertical bar key on all keyboards)
Produces this output only
Bytes 28941198 15506957
You can then send that output to your text file...
ie. netstat -e | grep32 "Bytes" >> text.txt
You can either have an icon setup to point to the text.txt file or have your program upload it's data from that file... whatever it is you are doing.
Just make sure where you place the grep, awk, sed, etc is in the path statement for the dos window or that you run your netstats from the directory they are located.
Unix has some very powerful text processing commands and the windows versions of them can be just as powerfull if harnessed properly.
For a deeper explanation on the power of grep see - pegasus.rutgers.edu/~elflord/unix/grep.html
Windows/Dos versions of these great Unix commands (grep/awk/sed/perl) can be found here - www.ibiblio.org/pub/micro/pc-stuff/freedos/gnuish/
They take a bit of getting used to but the rewards are worth it.
18 years 4 months ago #15669
by Alans
always Face your Fears...
Replied by Alans on topic Re: hi all need a lil help with batch files
Hi...
i'm a lil new to these subjects, i don't know why @ is used before echo?? can any one give any link for commands that used in batch files, any information i'll be thankfull..
i'm a lil new to these subjects, i don't know why @ is used before echo?? can any one give any link for commands that used in batch files, any information i'll be thankfull..
always Face your Fears...
Time to create page: 0.126 seconds