Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: parse string from textfile  with Batch (Dos 7.10)  (Read 3053 times)

0 Members and 1 Guest are viewing this topic.

uli_glueck

  • Guest
parse string from textfile  with Batch (Dos 7.10)
« on: November 08, 2005, 02:38:54 AM »
Hello,

I have a list with PC-names and ip adresses like this:

PC1. 1.1.1.1
PC3. 2.3.5.3
...

and need only the ip adress in a  variable.
Between PC-Name and IP-Adress is a blank.

The OS is M$-DOS 7.10

thanks in advance for any help
uli
« Last Edit: November 08, 2005, 02:40:14 AM by uli_glueck »

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: parse string from textfile  with Batch (D
« Reply #1 on: November 08, 2005, 04:45:50 AM »
From the command line:

for /f "tokens=1-2" %a in (ip.txt) do echo %b

From a batch file double up on the % symbols:

for /f "tokens=1-2" %%a in (ip.txt) do echo %%b

Note: I chose ip.txt as an arbitrary name for your file. You can change it accordingly.

Hope this helps.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

uli_glueck

  • Guest
Re: parse string from textfile  with Batch (D
« Reply #2 on: November 08, 2005, 06:18:50 AM »
Thanks for help Sidewinder.

But the f switch isnīt working in standalone dos.
(Thats my little problem)  :-(

uli

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: parse string from textfile  with Batch (D
« Reply #3 on: November 08, 2005, 06:57:56 AM »
Sorry about that. According to my trusty DOS manual, the FOR had no switches in those days. Without the /f switch you're SOL.

You may actually have to write a QBASIC program to read the file and process the data.

:-/
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

uli_glueck

  • Guest
Re: parse string from textfile  with Batch (D
« Reply #4 on: November 09, 2005, 03:41:09 AM »
I found a solution. :-)

Just for info:

The berkeley - tools  are a collection of unix tools for dos.
(It was commercial but is freeware now)

http://short.stop.home.att.net/freesoft/unix.htm

Now I am happy to have cut......  :-)  :-) :-)

uli
« Last Edit: November 09, 2005, 03:41:45 AM by uli_glueck »