bat winrar命令行 ftp的运用

2020-04-17 04:45

bat+winrar命令行+ftp的运用.txt10有了执著,生命旅程上的寂寞可以铺成一片蓝天;有了执著,孤单可以演绎成一排鸿雁;有了执著,欢乐可以绽放成满圆的鲜花。最近由于一个网站要频繁的改动,并且修改完后必须要马上部署到远程服务器上,前几次手动压缩,上传,解压,还能忍受,但是次数多了,就开始烦了。于是有了写个批处理文件的想法。 压缩上传文件zip.bat的内容如下:

rem 压缩网站文件目录,rar的命令行请参看rar帮助

\Files\\WinRAR\\WinRAR.exe\a -as -r -EP1 \\

rem 删除rar文件中的jar文件,这样就不用上传这些大块头了 \rem 上传

ftp -s:F:\\vc\\chatftp.txt 211.155.224.210 chatftp.txt文件内容如下: test test bell cd baoqf

put d:\\chat.rar bye exit

远程登录到服务器上,运行解压批处理文件: rem 解压,覆盖不提示

C:\\WinRAR\\WinRAR.exe x D:\\data\\baoqf\\chat.rar D:\\Tomcat\\webapps\\chat -r -y rem 深度拷贝,覆盖不提示

xcopy D:\\Tomcat\\webapps\\chat\\context D:\\Tomcat\\webapps\\chat /e /Y xcopy D:\\Tomcat\\webapps\\chat\\abc.properties D:\\Tomcat\\webapps\\chat\\WEB-INF\\classes\\abc.properties /Y rem 重启tomcat

d:\\tomcat\\bin\\tomcat.exe stop d:\\tomcat\\bin\\tomcat.exe start 批处理BAT文件运用

1. 所有内置命令的帮助信息 2. 环境变量的概念

3. 内置的特殊符号(实际使用中间注意避开) 4. 简单批处理文件概念 5. 附件1 tmp.txt 6. 附件2 sample.bat

###################################################################### 1. 所有内置命令的帮助信息

###################################################################### ver

cmd /? set /? rem /? if /? echo /? goto /? for /? shift /? call /?

其他需要的常用命令 type /? find /? findstr /? copy /?

______________________________________________________________________ 下面将所有上面的帮助输出到一个文件 echo ver >tmp.txt ver >>tmp.txt

echo cmd /? >>tmp.txt cmd /? >>tmp.txt

echo rem /? >>tmp.txt rem /? >>tmp.txt echo if /? >>tmp.txt if /? >>tmp.txt

echo goto /? >>tmp.txt goto /? >>tmp.txt echo for /? >>tmp.txt for /? >>tmp.txt

echo shift /? >>tmp.txt shift /? >>tmp.txt echo call /? >>tmp.txt call /? >>tmp.txt

echo type /? >>tmp.txt type /? >>tmp.txt

echo find /? >>tmp.txt find /? >>tmp.txt

echo findstr /? >>tmp.txt findstr /? >>tmp.txt echo copy /? >>tmp.txt copy /? >>tmp.txt type tmp.txt

______________________________________________________

######################################################################

2. 环境变量的概念

######################################################################

_____________________________________________________________________________ C:\\Program Files>set

ALLUSERSPROFILE=C:\\Documents and Settings\\All Users CommonProgramFiles=C:\\Program Files\\Common Files COMPUTERNAME=FIRST

ComSpec=C:\\WINNT\\system32\\cmd.exe NUMBER_OF_PROCESSORS=1 OS=Windows_NT

Os2LibPath=C:\\WINNT\\system32\\os2\\dll;

Path=C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\system32\\WBEM PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PROCESSOR_ARCHITECTURE=x86

PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 5, GenuineIntel PROCESSOR_LEVEL=6

PROCESSOR_REVISION=0605

ProgramFiles=C:\\Program Files PROMPT=$P$G SystemDrive=C:

SystemRoot=C:\\WINNT TEMP=C:\\WINNT\\TEMP TMP=C:\\WINNT\\TEMP

USERPROFILE=C:\\Documents and Settings\\Default User windir=C:\\WINNT

_____________________________________________________________________________

path: 表示可执行程序的搜索路径. 我的建议是你把你的程序copy 到 %windir%\\system32\\. 这个目录里面. 一般就可以自动搜索到. 语法: copy mychenxu.exe %windir%\\system32\\. 使用点(.) 便于一目了然

对环境变量的引用使用(英文模式,半角)双引号 %windir% 变量

%%windir%% 二次变量引用. 我们常用的还有

%temp% 临时文件目录 %windir% 系统目录 %errorlevel% 退出代码

输出文件到临时文件目录里面.这样便于当前目录整洁.

对有空格的参数. 你应该学会使用双引号(\来表示比如对porgram file文件夹操作 C:\\>dir p* C:\\ 的目录

2000-09-02 11:47 2,164 PDOS.DEF

1999-01-03 00:47

Program Files 1 个文件 2,164 字节

1 个目录 1,505,997,824 可用字节

C:\\>cd pro*

C:\\Program Files>

C:\\>

C:\\>cd \C:\\Program Files>

###################################################################### 3. 内置的特殊符号(实际使用中间注意避开)

###################################################################### 微软里面内置了下列字符不能够在创建的文件名中间使用 con nul aux \\ / | || && ^ > < *

You can use most characters as variable values, including white space. If you use the special characters <, >, |, &, or ^, you must precede them with the escape character (^) or quotation marks. If you use quotation marks, they are included as part of the value because everything following the equal sign is taken as the value. Consider the following examples:

(大意: 要么你使用^作为前导字符表示.或者就只有使用双引号\了) To create the variable value new&name, type: set varname=new^&name

To create the variable value \set varname=\

The ampersand (&), pipe (|), and parentheses ( ) are special characters that must be preceded by the escape character (^) or quotation marks when you pass them as arguments.

find \

IF EXIST filename. (del filename.) ELSE echo filename. missing

> 创建一个文件

>> 追加到一个文件后面

@ 前缀字符.表示执行时本行在cmd里面不显示, 可以使用 echo off关闭显示 ^ 对特殊符号( > < &)的前导字符. 第一个只是显示aaa 第二个输出文件bbb echo 123456 ^> aaa

echo 1231231 > bbb () 包含命令

(echo aa & echo bb)

, 和空格一样的缺省分隔符号. ; 注释,表示后面为注释 : 标号作用 | 管道操作

& Usage:第一条命令 & 第二条命令 [& 第三条命令...] 用这种方法可以同时执行多条命令,而不管命令是否执行成功 dir c:\\*.exe & dir d:\\*.exe & dir e:\\*.exe

&& Usage:第一条命令 && 第二条命令 [&& 第三条命令...]

当碰到执行出错的命令后将不执行后面的命令,如果一直没有出错则一直执行完所有命令; || Usage:第一条命令 || 第二条命令 [|| 第三条命令...]

当碰到执行正确的命令后将不执行后面的命令,如果没有出现正确的命令则一直执行完所有命令;

常用语法格式

IF [NOT] ERRORLEVEL number command para1 para2 IF [NOT] string1==string2 command para1 para2 IF [NOT] EXIST filename command para1 para2

IF EXIST filename command para1 para2 IF NOT EXIST filename command para1 para2 IF \IF \

IF NOT \

IF ERRORLEVEL 1 command para1 para2 IF NOT ERRORLEVEL 1 command para1 para2

FOR /L %%i IN (start,step,end) DO command [command-parameters] %%i

FOR /F \按照字母顺序 ijklmnopq依次取参数.

eol=c - 指一个行注释字符的结尾(就一个) skip=n - 指在文件开始时忽略的行数。

delims=xxx - 指分隔符集。这个替换了空格和跳格键的默认分隔符集。

###################################################################### 4. 简单批处理文件概念

######################################################################

echo This is test > a.txt type a.txt

echo This is test 11111 >> a.txt type a.txt


bat winrar命令行 ftp的运用.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:聚氨酯保温管分层及其作用有哪些?

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: