Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invoking Unix Tail Command through a java program

807606May 4 2007 — edited May 5 2007
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2007
Added on May 4 2007
9 comments
283 views