DOS批处理高级教程 第七章 DOS批处理编程高级技巧

2019-09-19 06:39:27王冬梅

其实可以将ftp命令组合保存为一个文本文件,然后用以下命令调用即可。

ftp -n -s:[[drive:]path]filename

上面的filename为ftp命令文件,包括登录IP地址,用户名、密码、操作命令等
例:

open 90.52.8.3 #打开ip
user iware #用户为iware
password8848 #密码
bin #二进制传输模式
prompt
cd tmp1 #切换至iware用户下的tmp1目录
pwd
lcd d:download #本地目录
mget * #下载tmp1目录下的所有文件
bye #退出ftp


六、用7-ZIP实现命令行压缩和解压功能

语法格式:(详细情况见7-zip帮助文件,看得头晕可以跳过,用到再学)

7z <command> [<switch>...] <base_archive_name> [<arguments>...]

7z.exe的每个命令都有不同的参数<switch>,请看帮助文件
<base_archive_name>为压缩包名称
<arguments>为文件名称,支持通配符或文件列表

其中,7z是至命令行压缩解压程序7z.exe,<command>是7z.exe包含的命令,列举如下:

a: Adds files to archive. 添加至压缩包
a命令可用参数:
-i (Include)
-m (Method)
-p (Set Password)
-r (Recurse)
-sfx (create SFX)
-si (use StdIn)
-so (use StdOut)
-ssw (Compress shared files)
-t (Type of archive)
-u (Update)
-v (Volumes)
-w (Working Dir)
-x (Exclude)

b: Benchmark

d: Deletes files from archive. 从压缩包中删除文件
d命令可用参数:
-i (Include)
-m (Method)
-p (Set Password)
-r (Recurse)
-u (Update)
-w (Working Dir)
-x (Exclude)

e: Extract解压文件至当前目录或指定目录
e命令可用参数:
-ai (Include archives)
-an (Disable parsing of archive_name)
-ao (Overwrite mode)
-ax (Exclude archives)
-i (Include)
-o (Set Output Directory)
-p (Set Password)
-r (Recurse)
-so (use StdOut)
-x (Exclude)
-y (Assume Yes on all queries)

l: Lists contents of archive.
t: Test
u: Update

x: eXtract with full paths用文件的完整路径解压至当前目录或指定目录
x命令可用参数:
-ai (Include archives)
-an (Disable parsing of archive_name)
-ao (Overwrite mode)
-ax (Exclude archives)
-i (Include)
-o (Set Output Directory)
-p (Set Password)
-r (Recurse)
-so (use StdOut)
-x (Exclude)
-y (Assume Yes on all queries)

七、调用VBScript程序

使用 Windows 脚本宿主,可以在命令提示符下运行脚本。CScript.exe 提供了用于设置脚本属性的命令行开关。

用法:CScript 脚本名称 [脚本选项...] [脚本参数...]

选项:
//B 批模式:不显示脚本错误及提示信息
//D 启用 Active Debugging
//E:engine 使用执行脚本的引擎

相关文章 大家在看