Hello...
I am trying to read free space available on remote servers. I am using
java and psexec for this. I have written code and am trying to invoke a batch file at the same time passing a variable to it. The batch file has psexec commands to determine the free space. I have 2 issues here.
1) when i am trying to invoke the batch file and pass server name as parameter, i get a message Error: ReadError
2) I am having trouble assigning the parameter that i am passing to a variable in the batch file.
Below is my java code:
import java.io.*;
import java.lang.*;
import java.util.*;
class PsexecnJava
{
public static void main(
String args[])
{
try
{
FileInputStream fstream = new FileInputStream("textfile.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String string1;
while ((string1 = br.readLine()) != null)
{
System.out.println ("Now logging onto Server: "+string1);
readVal(string1);
in.close();
}
}
catch (Exception e)
{
System.err.println("Error: " + e.getMessage());
}
}
public static void readVal(String st)
{
try
{
Runtime.getRuntime().exec("test1.bat st");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}