error process
This commit is contained in:
snoop 2017-04-12 15:08:55 +09:00
parent 121e32d3b3
commit 6d11a0a70c
2 changed files with 27 additions and 6 deletions

View File

@ -2,6 +2,8 @@ package com.loafle.overflow.crawler.wmi;
import java.util.*; import java.util.*;
/** /**
* Created by root on 17. 4. 12. * Created by root on 17. 4. 12.
*/ */
@ -67,10 +69,29 @@ public class WMICrawlerLinux extends WMICrawlerOS {
} }
result = result.trim(); result = result.trim();
List<Map<String,String>> resultMapList = new ArrayList<Map<String, String>>();
int errIdx = result.indexOf("ERROR:");
if(errIdx >= 0) {
int enterIdx = result.indexOf("\\n", errIdx);
if(enterIdx < 0) enterIdx = result.length();
String errStr = result.substring(errIdx + "ERROR:".length(), enterIdx);
Map<String,String> map = new HashMap<>();
map.put("ERROR", errStr);
resultMapList.add(map);
return resultMapList;
}
String[] lines = result.split("\\n"); String[] lines = result.split("\\n");
String line = ""; String line = "";
List<Map<String,String>> resultMapList = new ArrayList<Map<String, String>>();
List<String> columns = null; List<String> columns = null;
for (int indexI = 0 ; indexI < lines.length; ++indexI) { for (int indexI = 0 ; indexI < lines.length; ++indexI) {

View File

@ -52,11 +52,11 @@ public class WMICrawlerTest {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String id = "administrator"; // String id = "administrator";
String pw = "!@#$qwer1234"; // String pw = "!@#$qwer1234";
String nameSpace = "root/cimv2"; // String nameSpace = "root/cimv2";
String query = "select * from Win32_OperatingSystem"; // String query = "select * from Win32_OperatingSystem";
String ip = "192.168.1.1"; // String ip = "192.168.1.1";
map.put("id", "administrator"); map.put("id", "administrator");
map.put("pw", "!@#$qwer1234"); map.put("pw", "!@#$qwer1234");