WebbRuntime rt = Runtime.getRuntime (); String [] commands = {"system.exe", "-send" , argument}; Process proc = rt.exec (commands); I tried doing System.out.println (proc); but that did not return anything. The execution of that command should return two numbers separated by a semicolon. How could I get this in a variable to print out? Webb28 juni 2024 · Solution 1. The "su -c COMMAND" syntax is not really supported. For better portability, use something like this: p = Runtime.getRuntime ().exec ( "su"); stream = p.getOutputStream (); stream.write ( "busybox ifconfig wlan0 add xxxxxxxxxxxx"); The write () command doesn't exists as-is, but I'm sure you'll find how to write your stream to it ...
Java.lang.Runtime class in Java - GeeksforGeeks
Webb20 nov. 2012 · I've been trying to write a java program that uses the Runtime.getRuntime ().exec () method to use the command-line to run an instance of the program "tesseract". Some background, Tesseract is a free open source program that is used to perform OCR (Optical Character Recognition) on pictures. It takes in a picture file and outputs a text … WebbProcess ps = Runtime.getRuntime ().exec (shpath); ps.waitFor (); BufferedReader br = new BufferedReader (new InputStreamReader (ps.getInputStream ())); StringBuffer sb = new StringBuffer (); String line; while ( (line = br.readLine ()) != null) { sb.append (line).append ( "\n"); } String result = sb.toString (); System.out.println (result); } horizon forbidden west best weapons early
Safe usage of Runtime.getRuntime.exec (String [])
WebbLi3roは部分的に正しいです。聴いているプログラムにはstdout、stderr出力および出力用のバッファが限られています。それらを同時に聞いていない場合は、片方を読んでいる間に片方がいっぱいになります。 WebbProcess openProcess(final String[] cmdAttribs) throws IOException { return Runtime.getRuntime().exec(cmdAttribs); Webbpublic void importDateTohive () { try { String shpath = "/data/hadoop/percisettask/2_merge_userlog.sh"; Process ps = Runtime.getRuntime ().exec (shpath); ps.waitFor (); sb.append (line).append ("\n"); } String result = sb.toString (); System.out.println (result); } catch (Exception e) { e.printStackTrace (); } logger.info ("数 … lord of the hundreds root