how to execute the linux terminal custom command using java -


i have binary of engine developed hadoop(hdfs,hbase,mapreduce) , java use generate csv file. there operation performed engine table creation in hbase , generating csv file hbase. engine performed operation through command line , input given linux terminal in form of command. requirement connect linux terminal through java program , run commands not able run of command

there 2 option tried none of them worked. please provide suggestion or solution solve problem beginner of linux , hadoop figure out problem

1st-way

public class enginetest {  public static void main(string[] args) {     try { process process = runtime                 .getruntime()             .exec("/home/cloudera/pvgproto/base/ anloss -i ${tool_input}/census_10000_col5.csv  -d ${tool_def}/attr_all_def.txt -q k=14,dage=2 -g ${tool_res}/census_100_col8_gen.csv");              process.waitfor();         bufferedreader bufferedreader = new bufferedreader(                 new inputstreamreader(process.getinputstream()));         string line = "";         string output = "";         while ((line = bufferedreader.readline()) != null) {             output += line + "\n";         }         system.out.println(output);     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (interruptedexception e) {         // todo auto-generated catch block         e.printstacktrace();     } } 

2nd-way

i made 1 ex.sh file, in file put required command execution , call . sh file same java program same thing happened not running command through java program

 process process = runtime.getruntime().exec("/home/cloudera/pvgproto/base/ex.sh"); 

but if run same ex.sh linux terminal running command successfully.

ex.sh

# !/bin/bash  exec /home/cloudera/pvgproto/base/ anloss -i ${tool_input}/census_10000_col5.csv  -d ${tool_def}/attr_all_def.txt -q k=14,age=2 -g ${tool_res}/census_100_col8_gen.csv    echo command run 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -