找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20918|回复: 1

[网络连接] 批处理向局域网中完全共享的文本追加内容为何有时失败?

[复制链接]
发表于 2012-6-29 14:00:46 | 显示全部楼层 |阅读模式
我实现的如下功能:

假设局域网中有3台电脑A、B、C,我需要A、B2台电脑每天晚上2点自动开机(设置了BIOS自动唤醒,然后使用任务计划自动运行bat),将A机的a.txt 和 B机的b.txt 2个文本文件的内容都追加到C的一个共享文件夹中的C.txt中

这个功能很简单,我已实现了代码,但是我遇到个问题,就是不是每一次追加都是成功的,大概有40%左右的机率会失败,我在bat加入了ping 命,返回结果是通的
电脑启动后了,可以直接远程,证明网络确实是通的,但不知道为什么会出现失败,
不知道有哪位高人做过类似的功能,有没有遇到这样的情况?



以下是部分代码:

AUlog_server.txt  是C机上的文本文件,权限是 everyone 完全控制,B、C机文本的内容就是追加到此文本中。
AUlog_temp.txt 是A、B机本地的文本文件,内面的内容是前面的代码处理得来的。
AUlog_local.txt 是A、B机本地的文本文件,用途是:如果AUlog_temp.txt 追加到AUlog_server.txt 失败,就会改为追加在本地的AUlog_local.txt 中


  1. ping 10.10.43.45>>AUlog_local.txt
  2. ping -n 6 10.10.43.45>>AUlog_local.txt
  3. ping -n 6 10.10.43.45>>AUlog_local.txt

  4. type AUlog_temp.txt>>\\10.10.43.45\AUlog\AUlog_server.txt && echo 服务器日志同步:成功!>>\\10.10.43.45\AUlog\AUlog_server.txt && echo 服务器日志同步:成功!>>AUlog_temp.txt || echo 服务器日志同步:失败!>>AUlog_local.txt

  5. type AUlog_temp.txt >> AUlog_local.txt
  6. del AUlog_temp.txt
复制代码
下面是运行的结果(因为追加失败,所以结果在B、C机中的 AUlog_local.txt 内容):


Pinging 10.10.43.45 with 32 bytes of data:



Reply from 10.10.43.45: bytes=32 time=5ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time<1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64



Ping statistics for 10.10.43.45:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 5ms, Average = 1ms



Pinging 10.10.43.45 with 32 bytes of data:



Reply from 10.10.43.45: bytes=32 time=3ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64



Ping statistics for 10.10.43.45:

    Packets: Sent = 6, Received = 6, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 1ms, Maximum = 3ms, Average = 1ms



Pinging 10.10.43.45 with 32 bytes of data:



Reply from 10.10.43.45: bytes=32 time=5ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time<1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64

Reply from 10.10.43.45: bytes=32 time<1ms TTL=64

Reply from 10.10.43.45: bytes=32 time=1ms TTL=64



Ping statistics for 10.10.43.45:

    Packets: Sent = 6, Received = 6, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 5ms, Average = 1ms

服务器日志同步:失败!
 楼主| 发表于 2012-6-29 14:05:43 | 显示全部楼层
或者有什么方法保证追加时不失败或失败时不断尝试,直到追加成功为止。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-19 06:15 , Processed in 0.016803 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表