Staf 框架使用
概述:
1.可用于window/linux和window/linux之间的交互
如执行cmd,传输文件等
2.web自动化多机器调度运行,需要真机代开浏览器运行
代码复制到window机器-编译-运行 (全部通过master发送命令在调度机器运行)
STAF 172.29.49.9 PROCESS START COMMAND notepad
STAF 172.16.152.72 PROCESS START SHELL COMMAND
STAF 172.29.29.197 FS COPY Directory D:\\ TODIRECTORY D:\\aaa.txt TOMACHINE 172.16.152.76 RECURSE KEEPEMPTYDIRECTORIES
STAFHandle handle = null;
try {
handle = new STAFHandle("MyApp/Test");
} catch (STAFException e) {
System.out.println("Error registering with STAF, RC: " + e.rc);
}
String service = "PROCESS"; //命令执行
String request = "START COMMAND notepad"; //命令详情
try {
String result = handle.submit("172.29.49.9", service,
request);
STAFMarshallingContext mc = STAFMarshallingContext
.unmarshall(result);
Map mcMap = (Map) mc.getRootObject();
handle.unRegister();
} catch (STAFException e) {
System.out.println("run process error");
}