标题: 批处理中如何进行进程通讯?
[打印本页]
作者: peterdocter
时间: 2007-2-27 23:38
标题: 批处理中如何进行进程通讯?
@echo off
::生成ip号码
for /l %%i in (1,+1,10) do (
set ip="64.56.172.%%i"
%cd%\wget
http://%ip%
)
现在我的很大问题就是wget的提取有的内容如何做条件判断了?
也就是如何把wget的操作放在变量中,或者如何进行进程通讯?
wget如何找不到页面内容提示:
--10:26:58--
http://64.56.172.1/
=> `index.html'
Connecting to 64.56.172.1:80... failed: Connection refused.
--10:27:04--
http://64.56.172.2/
=> `index.html'
条件就是看有否?failed: Connection refused.
没有错误就是%ip%>>ip.txt
是否要用到两个for命令?我试过不成功,也许是我不什么会用这个for!
还有一个问题就for中的设置变量如何set好像没有循环值,就好像这个%ip%所有值都是同一个?是否要其它命令设置变量?
[
Last edited by peterdocter on 2007-2-27 at 11:45 PM ]
作者: NaturalJ0
时间: 2007-2-27 23:50
你查看下 errorlevel ,也许有用。
作者: vkill
时间: 2007-2-27 23:56
可以wget -o abc.txt http://
来在abc.txt中 find failed: Connection refused.
作者: peterdocter
时间: 2007-2-28 00:06
真得没有办法在批处理中把程序放到变量中吗?
作者: zerocq
时间: 2007-2-28 00:23
换curl下载试试
for /l %%i in (1,+1,10) do (
set ip="64.56.172.%%i"
%cd%\curl 地址|find 错误提示||echo %ip%>ip.txt
)
这样行不
作者: namejm
时间: 2007-2-28 00:27
for 语句内部使用前面定义的变量,要么启用变量延迟,要么使用 call 语句。
作者: vkill
时间: 2007-2-28 00:30
Quote: |
Originally posted by peterdocter at 2007-2-28 00:06:
真得没有办法在批处理中把程序放到变量中吗? |
|
去看看 gwet的参数
作者: peterdocter
时间: 2007-2-28 00:42
Quote: |
Originally posted by namejm at 2007-2-28 12:27 AM:
for 语句内部使用前面定义的变量,要么启用变量延迟,要么使用 call 语句。 |
|
要么启用变量延迟,是什么命令?
如何用call如何转这个变量参数?用%1这样就行了吗?
作者: peterdocter
时间: 2007-2-28 01:24
Quote: |
Originally posted by zerocq at 2007-2-28 12:23 AM:
换curl下载试试
for /l %%i in (1,+1,10) do (
set ip="64.56.172.%%i"
%cd%\curl 地址|find 错误提示||echo %ip%>ip.txt
)
这样行不 |
|
这样做不管有没有错误都把全部ip生成出来! find没有半点用!
作者: peterdocter
时间: 2007-3-1 03:42
set ip=64.56.172
::Generating IP number
for /l %%i in (1,1,20) do (
wget -t3 -O html.txt
http://%ip%.%%i -o %cd%\state.txt | find "connected" && echo
http://%ip%.%%i >>%ip%_http.txt
)
用&&就是不管url是事有效都不生成文件,而换成||反之!
Command1 &&Command2
只有在符号 && 前面的命令成功时,才运行该符号后面的命令。Cmd.exe 运行第一个命令,然后只有在第一个命令运行成功时才运行第二个命令。
Command1 || Command2
只有在符号 || 前面的命令失败时,才运行符号 || 后面的命令。Cmd.exe 运行第一个命令,然后只有在第一个命令未能运行成功(接收到大于零的错误代码)时才运行第二个命令。
到底有什么问题?是问题太难还是太简单一直没有几个人肯回答?