China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-02 05:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Extracting from a file by executing DOS commands View 1,285 Replies 12
Original Poster Posted 2006-09-27 05:59 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
For example, there is a file named 1.txt
I want to make a bat file
to implement this function:
open cmd.exe, then telnet the contents inside 1.txt. I don't know whether you can help me with this.
Floor 2 Posted 2006-09-27 06:23 ·  中国 广东 广州 广东金万邦科技投资有限公司(新一代数据中心)IDC机房(BGP)
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  Please describe the problem in a bit more detail. Also, the format of the contents in 1.txt is very important, please post part of it.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2006-09-27 06:25 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
Thank you so much
Floor 4 Posted 2006-09-27 06:26 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
Oops, I got excited just now and pressed ctrl+Enter

Let me describe it.

The contents in 1.txt are all like this:

11.11.11.1
22.11.215.4
They are all IPs, with no spaces in between.
I just want to be able to use a batch file to execute telnet on the IPs inside it.
Floor 5 Posted 2006-09-27 06:32 ·  中国 广东 广州 广东金万邦科技投资有限公司(新一代数据中心)IDC机房(BGP)
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  If you just want to telnet those IPs one by one, the code below will do, but this kind of batch telnet approach of yours is rather questionable: what's the use of telnetting so many IPs? You'd have to pause somewhere, right?


@echo off
for /f %%i in (1.txt) do telnet %%i
pause
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 6 Posted 2006-09-27 06:33 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
Thanks, I'll go test it.
My system is xp sp2
Floor 7 Posted 2006-09-27 06:35 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
I tried it, and it works.
But I want to know if it can be done not in the same window. I want multiple windows opened.
That is, telnet the first IP,
then a second DOS window telnetting the second IP,
and so on.

Many thanks
Floor 8 Posted 2006-09-27 06:37 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
Originally posted by namejm at 2006-9-27 06:32:
  If you just want to telnet those IPs one by one, the code below will do, but this kind of batch telnet approach of yours is rather questionable: what's the use of telnetting so many IPs? You'd have to pause somewh偠...

I don't need it to pause. I just want to telnet the IPs in 1.txt in multiple windows. Thanks.
Floor 9 Posted 2006-09-27 06:39 ·  中国 广东 广州 广东金万邦科技投资有限公司(新一代数据中心)IDC机房(BGP)
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  You can use the code below to open multiple telnet windows:

@echo off
for /f %%i in (1.txt) do start telnet %%i
pause
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 10 Posted 2006-09-27 06:40 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
telnet doesn't support reading commands from a file, don't bother trying it~

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 11 Posted 2006-09-27 06:45 ·  中国 河南 濮阳 联通
新手上路
Credits 18
Posts 7
Joined 2006-09-27 05:54
19-year member
UID 63776
Status Offline
Originally posted by namejm at 2006-9-27 06:39:
  You can use the code below to open multiple telnet windows:

@echo off
for /f %%i in (1.txt) do start telnet %%i
pause

Thank you so much. If anything comes up later, ``I'll still have to ask you for help. Thanks`` I'll remember you.
Floor 12 Posted 2006-09-27 08:02 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
This is the first time I've seen telnet used like this
Floor 13 Posted 2006-09-27 09:30 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
20-year member
UID 58987
From 湖南.娄底
Status Offline
I've never tried having telnet read information from a text file, and I don't know whether it works. I only know that ftp can read input information from a text file.
Forum Jump: