Invoking Unix Tail Command through a java program
807606May 4 2007 — edited May 5 2007I wrote a program to read the catalina.out log file.
But when I execute the program I am getting the below error
tail: -f option only appropriate for a single file
The program is as shown
public class ReadFile {
public static void main(String[] args) throws IOException{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("tail -f /Software_other/apache-tomcat-5.5.20/logs/catalina.out > /Software_other/hello.txt");
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null){
System.out.println(" --> " + line);
}
}
}
Can anybody please help in knowing the cause of the error.