[bat] column read

March 18, 2010 at 06:32:27
Specs: Windows XP
I have aquestion how to read a file and make a action in table.


file.txt looks like that:

1. <tab>address1 <tab> hostname1 <tab> port1 <tab> port12
2. <tab>address2 <tab> hostname2 <tab> port2 <tab> port22
3. <tab>address3 <tab> hostname3 <tab> port3 <tab> port34
4. <tab>address4 <tab> hostname4 <tab> port4 <tab> port42
5. <tab>address5 <tab> hostname5 <tab> port5 <tab> port52
6. <tab>address6 <tab> hostname6 <tab> port6 <tab> port62

I need a script whitch make something like this:

upload file.txt
take address1 and ping it in port1
then he take a hostname and ping in port12
then he save info in new file like
1.<tab>address1<tab>hostname1<tab>OK/NOT OK<tab>OK/NOT OK

he will do that for all of address and hostnames from list in file.txt.

I dont know how to take a name from table and use it as variable. How do
that whith a kolumn and tab char?

It gonna be a new version of this script: http://www.computing.net/answers/pr...

See More: [bat] column read

Report •

March 18, 2010 at 16:23:49
"upload", or download? (file.txt)
the columns part is easy, the port part is not, for me, because i don't understand how to ping a port.
here is something to start with:
@echo off>testfile & setlocal enabledelayedexpansion
:: thats a TAB, not a SPACE, after the equals!
(set tab= )
:get the file (?)
ftp -n -s:ftpscript
for /f "tokens=1-4" %%a in (file.txt) do (
set xx=not_ok
set yy=not_ok
ping /n 1 /w 3 %%a |find /i "received = 1" && set xx=ok
ping /n 1 /w 3 %%b |find /i "received = 1" && set yy=ok
>> testfile echo %%a%tab%%%b%tab%!xx!%tab%!yy!
::------ end script
i don't know what to do with the "port" items.

Report •
Related Solutions

Ask Question