Board logo

标题: 请教关于98 dos下 查询磁盘剩余空间的问题 [打印本页]

作者: fjdcxnp     时间: 2010-12-21 20:00    标题: 请教关于98 dos下 查询磁盘剩余空间的问题

各位大侠:
我目前遇到这样一个需求,在dos 系统下(dos version : Window 98 4.10.2222),在批处理文件中,查询一个磁盘(FAT,启动盘)剩余空间的大小,如果大于1G,提示用户。
通过这版本上DOS自带的命令或者外部命令(*.EXE 必须是免费允许各种用途)实现,熟悉的bat 编程的高手帮忙给点建议,谢谢哦
目前我有FIND.EXE,FDISK.EXE,CHKDSK.EXE等

[ Last edited by fjdcxnp on 2010-12-27 at 20:24 ]
作者: DOSforever     时间: 2010-12-21 21:41


  Quote:
Originally posted by fjdcxnp at 2010-12-21 20:00:
……
我想用for ,set 等语句来实现,但是这个版本下似乎不支持这些语句
(我试过,它不识别这些语句),
想通过find 语句实现,但是没找到这个版本下相应的find.exe

Windows 98 4.10.2222 所相应的 DOS 版本是 MS-DOS 7.10 ,不可能不支持 for 和 set 命令。for 和 set 是内部命令,不需要单独的可执行文件。
Windows 98 的 FIND.EXE 文件在 \WINDOWS\COMMAND 目录下。

不过我不需要用这些命令来实现你的目的。

[ Last edited by DOSforever on 2010-12-22 at 01:40 ]
作者: fjdcxnp     时间: 2010-12-22 18:14
非常感谢
1.我用for 语句,它提示是"syntax error"(如果没记错的话,总之提示错误),
以你看,可能是什么原因
2.请教还有什么办法可以实现,谢谢!
作者: DOSforever     时间: 2010-12-22 19:23
可以用 4DOS 的 @diskfree 变量函数

  Quote:
4DOS Help Topic:  @DISKFREE


@DISKFREE[d:,b|k|m|g]: Returns the amount of free disk space on the
specified drive.  DOS networks with large server disk drives (over 2 GB) may
report disk space values that are too small when @DISKFREE is used.  If this
occurs, it is because the network software does not report the proper values
to 4DOS.


作者: jinqiaoa1a     时间: 2010-12-23 08:18
两位高手的对话,我什么也看不懂,佩服并羡慕中
作者: fjdcxnp     时间: 2010-12-23 18:26


  Quote:
Originally posted by DOSforever at 2010-12-22 19:23:
可以用 4DOS 的 @diskfree 变量函数

感谢 DOSforever!!!
1由于其他原因可能我无法使用4DOS.... 。
2.我今天重新试了下for 语句,如你所言,是可以使用的,只是功能比较弱的,
以下是 这个版本的 for 语句
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead of
%variable.

3.我也找到的FIND.EXE

我想尝试通过for ,find 之类的DOS 内部或者外部命令实现,给点建议呀。

如果各位熟悉DOS bat 编程,提供些实现的示范呀,谢谢(本人不太熟悉DOS 编程,最近有临时需要才接触)

[ Last edited by fjdcxnp on 2010-12-27 at 19:42 ]
作者: fjdcxnp     时间: 2010-12-23 18:27


  Quote:
Originally posted by jinqiaoa1a at 2010-12-23 08:18:
两位高手的对话,我什么也看不懂,佩服并羡慕中

我最近刚接触....不懂
作者: DOSforever     时间: 2010-12-24 20:07
为什么无法使用 4DOS ?找不到下载?
你可以用“剩余空间”作为关键字在这个版块搜索一下。
作者: HAT     时间: 2010-12-26 16:12
DOS下如何检测分区的剩余空间?
http://www.cn-dos.net/forum/viewthread.php?tid=15017
作者: fjdcxnp     时间: 2010-12-26 18:53


  Quote:
Originally posted by DOSforever at 2010-12-24 20:07:
为什么无法使用 4DOS ?找不到下载?
你可以用“剩余空间”作为关键字在这个版块搜索一下。

谢谢。
不是的,
1.我目前做的是在原有的bat file上添加些东西,如果改用4DOS可能会影响原有的应用,各种*.EXE
2.我查了4DOS , http://en.wikipedia.org/wiki/4DOS
它对商业用途有限制,不是随意用的,由于不是我自己个人使用,不想惹麻烦(虽然惹麻烦的几率应该为0)

我在发帖之前查过目前的已有的查询剩余空间的办法,但我无法使用上,
1.用for
http://www.cn-dos.net/forum/viewthread.php?tid=19738
我试过,for 语句在我的目前的DOS 下很弱,不支持-f.....
2.用GET.EXE
http://www.cn-dos.net/forum/viewthread.php?tid=15017
GET.EXE 应该是正版收费的..

现在试着用for 和 FIND.EXE ,但估计挺麻烦的。
作者: fjdcxnp     时间: 2010-12-26 18:54


  Quote:
Originally posted by HAT at 2010-12-26 16:12:
DOS下如何检测分区的剩余空间?
http://www.cn-dos.net/forum/viewthread.php?tid=15017

谢谢,但是GET.EXE 并非开源免费随便用的,
谢谢
作者: DOSforever     时间: 2010-12-26 20:52
呵呵,谢谢 fjdcxnp ,看来你还挺仔细的。我只记得 4DOS 从 7.50 版起就是 Freeware 了,还没注意到你说的“商业用途有限制”。我看了下你给的 4DOS 的 Wiki 链接,我的英文不太好,按照 History and current status 中这段话的意思

  Quote:
Originally distributed as shareware, 4DOS has been later released as unsupported freeware. Currently, the source code is available under a modified MIT License but it "may not be used in any commercial product without written permission from Rex Conn"

我的理解是,源代码不能用于商业产品,除非得到 Rex Conn 的许可,但 4DOS 软件本身是 Freeware 。

这是 7.50 版的 LICENSE.TXT 内容:

  Quote:

Copyright (c) 1989-2004 JP Software, Inc.
-----------------------------------------

4DOS (including software, documents, or other related items) is being
provided by JP Software under the following license. By obtaining,
using and/or copying this work, you (the licensee) agree that you have read,
understood, and will comply with the following terms and conditions:

Permission to use, copy, modify, and distribute this software and its
documentation, with or without modification, for any purpose and without fee
or royalty is hereby granted, provided that you include the following on ALL
copies of the software and documentation or portions thereof, including
modifications, that you make:

  1. The full text of this notice in a location viewable to users of the
  redistributed or derivative work.

  2. Notice of any changes or modifications to the files, including the date
  changes were made.

  3. You may charge a distribution fee for the physical act of transferring a
  copy, and you may at your option offer warranty protection in exchange for a
  fee.

  4. You may not copy, sublicense, distribute or transfer 4DOS except as
  expressly provided under this License Agreement, without prior written
  permission from JP Sofrware. Any attempt otherwise to copy, sublicense,
  distribute or transfer 4DOS is void and your rights to use the program
  under this License agreement shall be automatically terminated.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND JP SOFTWARE MAKES
NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

JP SOFTWARE WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.

The name of JP Software may NOT be used in advertising or publicity
pertaining to the software without specific, written prior permission.
Title to copyright in this software and any associated documentation will
at all times remain with JP Software.

这是 8.00 版的 LICENSE.TXT 内容:

  Quote:

Copyright (c) 1989-2004 JP Software, Inc.
-----------------------------------------

4DOS (including software, documents, or other related items) is being
provided by JP Software under the following license. By obtaining,
using and/or copying this work, you (the licensee) agree that you have read,
understood, and will comply with the following terms and conditions:

Permission to use, copy, modify, and distribute this software and its
documentation, with or without modification, for any purpose and without fee
or royalty is hereby granted, provided that you include the following on ALL
copies of the software and documentation or portions thereof, including
modifications, that you make:

  1. The full text of this notice in a location viewable to users of the
  redistributed or derivative work.

  2. Notice of any changes or modifications to the files, including the date
  changes were made.

  3. You may charge a distribution fee for the physical act of transferring a
  copy, and you may at your option offer warranty protection in exchange for a
  fee.

  4. You may not copy, sublicense, distribute or transfer 4DOS except as
  expressly provided under this License Agreement, without prior written
  permission from JP Sofrware. Any attempt otherwise to copy, sublicense,
  distribute or transfer 4DOS is void and your rights to use the program
  under this License agreement shall be automatically terminated.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND JP SOFTWARE MAKES
NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

JP SOFTWARE WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.

The name of JP Software may NOT be used in advertising or publicity
pertaining to the software without specific, written prior permission.
Title to copyright in this software and any associated documentation will
at all times remain with JP Software.

你看一下,如果使用的话会不会给你带来版权上的麻烦。

[ Last edited by DOSforever on 2010-12-26 at 20:54 ]
作者: DOSforever     时间: 2010-12-26 21:08
接下来我们再讨论下技术性问题

  Quote:
Originally posted by fjdcxnp at 2010-12-26 18:53:

1.我目前做的是在原有的bat file上添加些东西,如果改用4DOS可能会影响原有的应用,各种*.EXE

关于改用 4DOS 后对原有 BAT 的影响,我是这么认为的:
http://www.cn-dos.net/forum/viewthread.php?tid=15214#pid91455

  Quote:
4DOS与传统的COMMAND.COM相比变化确实很大,但它并不是改变了COMMAND.COM原有的语法和参数,而是在它的基础上加以扩充,你也可以完全按照使用COMMAND.COM的习惯来使用它,原来在COMMAND.COM下编写的BATCH可以不加任何修改地在4DOS下运行……

当然,我本人没经过100%验证,具体你的应用还要你自己验证下。

  Quote:
Originally posted by fjdcxnp at 2010-12-23 18:26:

如果各位熟悉DOS bat 编程,提供些实现的示范呀,谢谢(本人不太熟悉DOS 编程,最近有临时需要才接触)

BAT 根本算不上编程,编写批处理不叫编程,编写批处理根本上不了编程这个档次。在这里,我看到许多人要个什么批处理代码什么的,我对此嗤之以鼻,代码这个词我认为批处理还没这个资格用。
作者: fjdcxnp     时间: 2010-12-27 19:51


  Quote:
Originally posted by DOSforever at 2010-12-26 20:52:
呵呵,谢谢 fjdcxnp ,看来你还挺仔细的。我只记得 4DOS 从 7.50 版起就是 Freeware 了,还没注意到你说的“商业用途有限制”。我看了下你给的 4DOS 的 Wik ...

谢谢提供原版声明,我看了下,没发现什么问题,应该也能用
(与GNU还是不同的,不太确定),
谢谢
作者: fjdcxnp     时间: 2010-12-27 20:10


  Quote:
Originally posted by DOSforever at 2010-12-26 21:08:
接下来我们再讨论下技术性问题


关于改用 4DOS 后对原有 BAT 的影响,我是这么认为的:
http://www.cn-dos.net/forum/viewthread.php?tid=15214#pid91455

...

1.我搜索了下4DOS ,还没找到合适的下载,也没试过
2.我现在要做的磁盘查询相对与目前这个bat file 实现的功能,算是很小的一部分,如果因此改用4DOS ,风险,代价还是大的。
所以我倾向于用目前已有的一些免费的EXE来实现,
感谢

看过论坛极类似的问题,好像也没有解决
http://www.cn-dos.net/forum/view ... 9%E7%A9%BA%E9%97%B4
作者: fjdcxnp     时间: 2010-12-29 20:23
我通过sed.exe (GUN FOR MS-DOS sed3028a)和 string.com 实现
实现过程还是比教麻烦的(应该有更好的办法)
感谢各位,特别是DOSforever !

[ Last edited by fjdcxnp on 2010-12-29 at 20:25 ]
作者: DOSforever     时间: 2010-12-29 20:47
最好的方法就是我说的 4DOS ,我看是找不到比这更好的方法了。依我看,假如你原先的批处理全部用 4DOS 的命令来编写或许更简便、更省力。

4DOS 7.50 版下载:
ftp://ftp.jpsoft.com/4dos/4dos750.exe

4DOS 8.00 版下载:
http://4dos.isgreat.org/download.php
作者: fjdcxnp     时间: 2010-12-30 09:51


  Quote:
Originally posted by DOSforever at 2010-12-29 20:47:
最好的方法就是我说的 4DOS ,我看是找不到比这更好的方法了。依我看,假如你原先的批处理全部用 4DOS 的命令来编写或许更简便、更省力。

4DOS 7. ...

那两个下载地址好像都不能用呀
作者: fjdcxnp     时间: 2010-12-30 09:54


  Quote:
Originally posted by fjdcxnp at 2010-12-29 20:23:
我通过sed.exe (GUN FOR MS-DOS sed3028a)和 string.com 实现
实现过程还是比教麻烦的(应该有更好的办法)
感谢各位,特别是DOSforever !

[ Last edited by fjdcxnp on 2010-12-29 at 20:25 ]

有个小问题,
在 我的batfile 中 dir | sed -n '/bytes free/p' >atest.txt
或者 sed -e 's/ //g' -e 's/,//g' atest.txt >atest1.txt 之后
bat file 就停止了,必须手动按 enter 键才会继续执行接下来的语句?
作者: DOSforever     时间: 2010-12-30 13:39


  Quote:
Originally posted by fjdcxnp at 2010-12-30 09:51:


那两个下载地址好像都不能用呀

第一个地址也就是 JPSoft 的官方网站可以下,我试过
第二个地址可能我直接给出下载页面链接不行,你到它的主页面上再点下载链接吧
http://4dos.isgreat.org/