Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> execute pig command in Java program


Copy link to this message
-
execute pig command in Java program
Hi,

I used to write PHP code to execute pig command, it worked well,
Now I switch to Java but seems it won't work, here is my code:

String pigCommand = "pig -x local -p ouput=/tmp my_pig_script.pig";

Runtime r = Runtime.getRuntime();
Process p;

int exitVal;

try {
p = r.exec(pigCommand);
exitVal = p.waitFor();
BufferedReader br = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line = null;

while((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();

System.out.println("exitVal: " + exitVal);
System.out.println("Done");

If I run the that pig command in console directly, it works, if I replace
that
Pig command with other shell command say 'ping www.yahoo.com', and run the
java
Program, it works too. So what might be the problem?

Thanks.
+
Cheolsoo Park 2013-01-24, 20:21
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB