{"id":5028,"date":"2014-03-30T18:07:35","date_gmt":"2014-03-30T18:07:35","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-while-running-shell-script-using-java-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:07:35","modified_gmt":"2014-03-30T18:07:35","slug":"problem-while-running-shell-script-using-java-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-while-running-shell-script-using-java-collection-of-common-programming-errors\/","title":{"rendered":"problem while running shell script using java-Collection of common programming errors"},"content":{"rendered":"<p>Try this, it will definitely works.<\/p>\n<p>Shell Script test.sh code<\/p>\n<pre><code>   #!\/bin\/sh\n   echo \"good\"\n<\/code><\/pre>\n<p>Java Code to execute shell script test.sh<\/p>\n<pre><code>          try {\n                Runtime rt = Runtime.getRuntime();\n                Process pr = rt.exec(new String[]{\"\/bin\/sh\", \"\/tmp\/padm\/.test.sh\"});\n\n                BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));\n                String line = \"\";\n                while ((line = input.readLine()) != null) {\n                    System.out.println(line);\n                }\n            } catch (Exception e) {\n                System.out.println(e.toString());\n                e.printStackTrace();\n            }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Try this, it will definitely works. Shell Script test.sh code #!\/bin\/sh echo &#8220;good&#8221; Java Code to execute shell script test.sh try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(new String[]{&#8220;\/bin\/sh&#8221;, &#8220;\/tmp\/padm\/.test.sh&#8221;}); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line = &#8220;&#8221;; while ((line = input.readLine()) != null) { System.out.println(line); } } catch (Exception e) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5028","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5028"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5028\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}