1

in a simple html file opened locally via firefox I need some javascript code to execute a command (maybe "ls") and get it's result in a string I can use in js/jquery to alter the page contents.

I already know this is a generally bad idea, but I have to make this little local html file capable of running several scripts without a server and without cgi.

In the past I've used to install a plugin in TiddlyWiki (www.tiddlywiki.com) to execute external commands (firefox requested authorization for every operation), so javascript can do it, but how to get command result in js after execution?

Vasily
  • 316
  • 3
  • 12
  • You'll need some server side code here. So either create a form and server side submit handler, or use ajax. – jrummell Dec 19 '11 at 16:19
  • Thanks jrummell for your support, but as I specified I can't use server side code. I need something like ajax (I will use jquery to alter page contents after I obtained the result string from a script) but whitout server or cgi. I'am sure a good javascript hacker can do this. – Vasily Dec 19 '11 at 16:24
  • The only client script the might work is VBScript, but only in IE. And as you and jfriend00 have pointed out, this is terrible practice because of security concerns. Based on your requirements, it sounds like a desktop application would be a much better option. – jrummell Dec 19 '11 at 17:50
  • Ok, it seems I was wrong. Thanks, anyway! – Vasily Dec 19 '11 at 17:59

1 Answers1

1

I don't believe there's any way to do this without a cooperating browser plug-in. The browser plug-in would be told what command to execute via javascript, it would go execute that command and then call you back with a callback when the results were available. This could be very dangerous as giving the browser access to your local system in almost anyway opens you up to lots of types of attacks (which is why browsers don't offer this capability).

jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • Thanks jfriend00, I can't use a browser plugin, so it seems there is no way to go. Giving browser access to local system would not be a concern in my case, as I am the only user of this application, but if this is not possible I think there are very good reasons as you pointed out. I am only upset about using a server for such a simple task... – Vasily Dec 19 '11 at 18:04