All Forums General
sakthik 17 posts Joined 10/10
15 Nov 2010
Executing Fastload through Java Hang in unix

Hi All,

When we try to execute simple Fastload script through Java in unix , it hangs .
same when We tried executing it manually through fastload command "fastload < /temp/data/fastload.txt > /temp/data/fastload.log" it works fine.

Given script which we used it for testing

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class FastLoadTest {
public static void main(String a[]){
int rc = 0;
try {
String cmd = "fastload < /temp/data/fastload.txt > /temp/data/fastload.log";
System.out.println(cmd);
Process p = Runtime.getRuntime().exec(cmd);
rc = p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
line = reader.readLine();
}

} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println(rc);
}
}

Need your help.

Thanks

tomnolan 594 posts Joined 01/08
16 Nov 2010

There are at least a couple of problems with your program.

First, you are using the shell IO redirect operators in your command. Those are only implemented by the shell. If you want to use them, then you need to run a shell, not fastload directly.

String cmd = "sh -c \"fastload < /temp/data/fastload.txt > /temp/data/fastload.log\"";

Second, why are you getting the Process object's InputStream and reading from that? That doesn't make any sense, since you are redirecting the output to a file.

sakthik 17 posts Joined 10/10
17 Nov 2010

Thanks a lot. It's working now.

gautam.aditya97 1 post Joined 05/11
28 May 2011

hi

I am facing a similar situation where we invoke fastload in a Java program using process builder on unix platform. We read inputStream and write to a log file. Also, using outPurStream we try to write script to fastLoad process. And then we wait for fastload process to finish. But it hangs waiting for fastload process.

Any help.. Thanks

You must sign in to leave a comment.