{"id":20,"date":"2005-05-20T09:25:00","date_gmt":"2005-05-20T14:25:00","guid":{"rendered":"http:\/\/stein.everybody.org\/brain\/how-to-call-a-system-command-from-javascript\/"},"modified":"2011-03-10T10:57:34","modified_gmt":"2011-03-10T15:57:34","slug":"how-to-call-a-system-command-from-javascript","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/how-to-call-a-system-command-from-javascript\/","title":{"rendered":"How to call a system command from Javascript"},"content":{"rendered":"<p><strong>This will not work from a browser.<\/strong>  This works with LiveConnect to do server-side scripting for applications that support it (like IBM Tivoli Directory Integrator).<\/p>\n<p>var runtime = java.lang.Runtime.getRuntime();<br \/>\nvar process = runtime.exec(command);<br \/>\nprocess.waitFor();<br \/>\nvar exitValue = process.exitValue();<br \/>\nif (exitValue == 0)<br \/>\n&#8230;<\/p>\n<p>Ideally, you should pass the command as an array.  Also, you should <a href=\"http:\/\/www.javaworld.com\/javaworld\/jw-12-2000\/jw-1229-traps.html\">handle the streams<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This will not work from a browser. This works with LiveConnect to do server-side scripting for applications that support it (like IBM Tivoli Directory Integrator). var runtime = java.lang.Runtime.getRuntime(); var process = runtime.exec(command); process.waitFor(); var exitValue = process.exitValue(); if (exitValue == 0) &#8230; Ideally, you should pass the command as an array. Also, you should [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,36],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-directory-integrator","category-liveconnect"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}