您的位置:首页 > 其它

再谈windows下几个重要的DOS命令和命令组合,工作中常用

2013-12-16 11:18 661 查看
以下是我常用的一些命令或命令组合, 以后会陆续补充。

1. dir 用于查找文件或者目录:
例如:

D:\asa120>dir /L /S dbole*.dll
2012-03-28 11:13 1,028,472 dboledb12.dll

2012-03-28 11:13 383,352 dboledba12.dll

2 个文件 1,411,824 字节

驱动器 D 中的卷没有标签。

卷的序列号是 0007-3F2D

D:\asa120\BIN32 的目录

所列文件总数:

2 个文件 1,411,824 字节

0 个目录 37,096,058,880 可用字节

C:\SAP\MobilePlatform\Servers\UnwiredServer>dir /b/l/s *.txt

c:\sap\mobileplatform\servers\unwiredserver\adminclientapi\com.sybase.sup.adminapi\samples\readme.txt

c:\sap\mobileplatform\servers\unwiredserver\config\doebundle-version.txt

c:\sap\mobileplatform\servers\unwiredserver\logs\errorlog-sampledb.txt

c:\sap\mobileplatform\servers\unwiredserver\logs\errorlog.txt

c:\sap\mobileplatform\servers\unwiredserver\logs\ampadminobjects\pekn50822106a_obmo_ampadminobjects_20131120t164658.txt

2. taskkill杀死某进程及子进程
taskkill /T /F /IM OBServiceManager.exe

3. 判断某端口号是否被占用, 以及地程的id
e.g. 看5001被哪个进程占用

netstat -ano | findstr 5001 | findstr LISTEN

D:\ASA120\BIN64>netstat -ano | findstr 5001 | findstr LISTEN

TCP 0.0.0.0:5001 0.0.0.0:0 LISTENING 18340

TCP [::]:5001 [::]:0 LISTENING 18340

一看进程ID是18340

tasklist | findstr 18340
得到结果:
D:\ASA120\BIN64>tasklist | findstr 18340

mlsrv16.exe 18340 Services 0 630,696 K

4. 错误的重定向
1) 使用 1>a.txt 2>a.txt

  1>nul 2>nul

1指的是标准输出 2指的是错误输出,1是默认的,可以省去

2) 两者一块儿使用,可以直接用 >a.txt 2>&1
示例:
D:\ASA120\BIN64>a.bat > a.txt 2>&1

D:\ASA120\BIN64>more a.txt

'a.bat' is not recognized as an internal or external command,

operable program or batch file.

D:\ASA120\BIN64>a.bat 1>a.txt 2>a_err.txt

D:\ASA120\BIN64>more a.txt

D:\ASA120\BIN64>more a_err.txt

'a.bat' is not recognized as an internal or external command,

operable program or batch file.

5. 使用find, findstr查找文件内容

1) find和dir结合
C:\SAP\MobilePlatform\Servers\UnwiredServer\logs>dir /s/l/b *.txt | find /i "mlsrvwrapper"

c:\sap\mobileplatform\servers\unwiredserver\logs\observicemanager\pekn50822106a_mlsrvwrapper_observicemanager_20131120t105900.txt

C:\SAP\MobilePlatform\Servers\UnwiredServer\logs>dir /s/l/b *.txt | find /N /i "mlsrvwrapper"

[19]c:\sap\mobileplatform\servers\unwiredserver\logs\observicemanager\pekn50822106a_mlsrvwrapper_observicemanager_20131120t105900.txt

for %f in (*.bat) do find "PROMPT" %f
dir c:\ /s /b | find "CPU"

2) findstr 直接查找

C:\SAP\MobilePlatform\Servers\UnwiredServer\logs>findstr /C:mlsrv /S *

errorlog.txt:I. 11/20 19:02:41. Disconnected TCPIP client's AppInfo: IP=10.128.98.225;HOST=PEKN50822106A;OSUSER=SYSTEM;OS='Windows 7 Build 7601 Service Pack 1';EXE=C:\SAP\MobilePlatform\Servers\SQLAnywhere16\Bin64\mlsrv16.exe;PID=0x4048;THREAD=0x110;VERSION=16.0.0.1691;API=ODBC;TIMEZONEADJUSTMENT=480

errorlog.txt:I. 11/20 19:02:41. Disconnected TCPIP client's AppInfo: IP=10.128.98.225;HOST=PEKN50822106A;OSUSER=SYSTEM;OS='Windows 7 Build 7601 Service Pack 1';EXE=C:\SAP\MobilePlatform\Servers\SQLAnywhere16\Bin64\mlsrv16.exe;PID=0x4048;THREAD=0x4a3c;VERSION=16.0.0.1691;API=ODBC;TIMEZONEADJUSTMENT=480

errorlog.txt:I. 11/20 19:02:41. Disconnected TCPIP client's AppInfo: IP=10.128.98.225;HOST=PEKN50822106A;OSUSER=SYSTEM;OS='Windows 7 Build 7601 Service Pack 1';EXE=C:\SAP\MobilePlatform\Servers\SQLAnywhere16\Bin64\mlsrv16.exe;PID=0x4048;THREAD=0x20c8;VERSION=16.0.0.1691;API=ODBC;TIMEZONEADJUSTMENT=480

6. 系统服务的相关命令
sc delete <服务名> 删除某服务 (参数可以是服务名,也可以是它的显示名)
添加依赖关系:
C:\SAP\MobilePlatform\Servers\UnwiredServer\logs>sc config "SAPMobileServer" depend= "SQLANYs_SAPMobilePlatformDatabase"

[SC] ChangeServiceConfig SUCCESS
上述命令将服务SAPMobileServer依赖于SQLANYs_SAPMobilePlatformDatabase.
只能是服务名,不是服务的显示名。两者有区别

sc query | findstr SAPMobileServer

C:\SAP\MobilePlatform\Servers\UnwiredServer\logs>sc query | findstr SAPMobileServer

SERVICE_NAME: SAPMobileServer

7. setx 设定环境变量
setx JAVA_HOME C:\ASE\Java\jdk /M

linux:

mount -t cifs -o username=***,password=**** //10.1.3.73/linux $BU_PATH

mount -t cifs -o username=***, //10.1.3.73/linux/mcsf $BU_PATH

mount -t cifs -o username=***,password=*** \\Sw-d0626\linux $BU_PATH

umount $BU_PATH

ulimit -c unlimited

umount /home/jingbo/mcsfware

export BU_PATH=/home/jingbo/mcsfware

echo $BU_PATH

gcc -c -I /UIH/include/external boostsend.c -o btest3.o

gcc -m64 -I /UIH/include/external boostsend.c -o btest3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: