Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Linux net command showing incorrect output if executing from java.

Reply
Thread Tools

Linux net command showing incorrect output if executing from java.

 
 
mickeyteg mickeyteg is offline
Junior Member
Join Date: Nov 2010
Posts: 1
 
      11-04-2010
Hi I am trying to use net command on linux to check the registry value on windows PC, however the command is throwing "invalid registry path" output although it runs fine when I execute it from linux termial. I am tried using encapsulation the command String in an array, but it didn't help. Please see the code below:

//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
import java.io.*;

public class ChkBpower {
public static void main(String[] args) {
checkBpower(12;
}


public static void checkBpower (int TTL){
int ttl = TTL;
System.out.println("Hello3");
String ip = "20.198.36.28";
String credentials ="bpwrlab/Administrator%Confmgmt1";//"asiapac/gjagdeosingh%M@nu2281";
String chkBcmd = "net rpc registry enumerate '\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Marimba' -I " + ip + " -U " + credentials ;
String chkBstatus = "net rpc service status cscmarimba -I " + ip + " -U " + credentials + "| grep -b 'service' | awk '{print $4}'";
String startBpower = "net rpc service start cscmarimba -I " + ip + " -U " + credentials;

if (ttl>=100 && ttl<=12{

System.out.println(ttl);
System.out.println(chkBcmd);

try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(chkBcmd);
InputStream stderr = p.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<ERROR>");
System.out.println(br.readLine());
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("</ERROR>");
int exitVal = p.waitFor();
System.out.println("Process exitValue: " + exitVal);
}
catch (Throwable t)
{
t.printStackTrace();
}


//System.out.println("test");
// BufferedReader br = new BufferedReader(new
// InputStreamReader(p.getInputStream()));
// String line;
// System.out.println(br.readLine());

// while ((line = br.readLine()) != null)
// {
// System.out.println(br.readLine());}
// int intline=0;
// if (intline==1){
// Process p2 = r.exec(chkBstatus);
// BufferedReader in2 = new BufferedReader(new
// InputStreamReader(p2.getInputStream()));
// if (in2.readLine()=="stopped."){
// r.exec(startBpower);
// }
// in2.close();
// }
// br.close();
// } //try

// catch (IOException e) {
// System.out.println(e);
// }
}
}

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
incorrect showing html generated by javascript in .aspx file Fixer ASP .Net 0 10-03-2007 05:33 AM
Two PIX connected to 3630 which is showing incorrect ARP entires skoon Cisco 0 08-06-2007 02:39 AM
Run command showing a tftp command on it's own kvine@marchnetworks.com Computer Support 2 01-12-2007 02:49 PM
Incorrect filenames are being showing in downloading. =?Utf-8?B?SW5jb3JyZWN0IGZpbGVuYW1lcyBpbiBkb3dubG9hZCBsaW5rLg==?= ASP .Net 2 10-18-2005 07:58 AM
Nesgroups showing incorrect 'unread' messages. Andy J. Firefox 15 09-19-2005 10:27 AM



Advertisments