Javaからarguments変数を渡してシェルファイルを実行しようとしています。javaからintとstringの引数を渡してシェルファイルを実行する
上記の変数start、end、countryのような変数を渡すjavaコードから、シェルファイルscript.shを呼び出す必要があります。
int start = 10;
int end = 100;
String country = India;
String scriptlocation = scriptloc+"/script.sh";
ProcessBuilder processBuilder = new ProcessBuilder(scriptlocation);
processBuilder.environment().put("start", start);
processBuilder.environment().put("end", end);
processBuilder.environment().put("country", country);
どこ開始と終了の整数であり、国は...文字列 変数であるので、上記の方法は、int型の変数では動作しません。
私も、私はこの方法は、それがスタートのために10、100及びインドのような変数の値を取るために持っている.Because仕事をしたりしませんよく分からない以下の方法
ProcessBuilder pb2=new ProcessBuilder("/bin/sh",
"-c",
"start=start end=end country=country scriptlocation");
を試みた端部と、国の変数..親切にお勧めします。