Nmap Development mailing list archives

Help required:to execute nmap.exe from java app


From: guoxing.guo <guoxing.guo () wdk-networks com>
Date: Thu, 8 Sep 2011 09:27:06 +0800

Hi,all
I was trying to execute nmap.exe from my java app(JDK1.6+WinXP). But it seems never return.
Code following:

Process process = Runtime.getRuntime().exec("E:\workspace2\NM_Server\3rdparty\nmap\windows/nmap -O 172.16.164.64");
process.waitFor();

byte[] buffer = new byte[256];
int cnt = 0;
InputStream is = process.getInputStream();
StringBuffer sb = new StringBuffer();
while((cnt=is.read(buffer))>-0){
  sb.append(new String(buffer,0,cnt));
}
is.close();
return sb.toString();

//Not work.

It can show the expected infomation when I execute "E:\workspace2\NM_Server\3rdparty\nmap\windows/nmap -O 
172.16.164.64" in a command line window. Someone in stackoverflow.com says it maybe lost the PATH env . Actually it 
works after I set PATH='' in the CMD window.

I found a related thread on http://seclists.org/nmap-dev/2008/q2/498 . But it seems have not been solved.

Any idea to out of this or workaround it will be appreciated.

Regards
Simon KWOK(郭国兴)
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: