Link to home
Start Free TrialLog in
Avatar of duncanb7
duncanb7

asked on

run window command on browser with javascript and its concept

Dear Experts,
one day, I found one updated javascript application code  embedded into the webpage I access daily and my apache server php coding could not collect the data information becoz  the code is written in javascript, it mean only allow client collect in browser to collect the data. Finally, I solved it by node.js installed in my apached sever and using php command of exec("node myjavscript.js")

-First question is brower can run javascript code if javascript is enabled on browser that is
NOT depended  on linux or window system , Right ? In other words, javascript running is
Not related to computer system architecture.

-Seoncd ,node.js installed in my server act as javascript complier similar to the action to C complier.Besides that, I don't find any special on node.js since a lot feaures which can be done on php coding on server and javascript on client. And for http access, we can have apache server instead of node.js run-time background process .  Any advise about this subject.

-Finally, When I try to think about " run window command on my browse at client side or home computerr", I don't know how node.js will assist on this from his child_process module. Any comment on this? My this  topic question is similar to ask how flash running into browser when flash run-time is installed on our window computer.

Please advise

Duncan
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I'm not sure I can answer all of the questions here, but I might be able to give you a head-start.  Before you do anything else, please read this article:
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

JavaScript is a client-side technology.  The JavaScript statements are prepared on the server and sent to the browser, in response to an HTTP request. Then the server disconnects.  So from the client perspective, the server software does not matter -- as long as valid JavaScript was sent to the client, the client is capable of running it.

Node.JS bends this design a bit by implementing a server-side programming language that looks much like the client-side javaScript language.  Node is an event machine for routing many concurrent requests on the server.  Think of it as if it were Python or Ruby on Rails.  It's not a part of the LAMP stack.

Things like this: "one day, I found one updated javascript application code embedded into the webpage..." usually mean your scripts were hacked.  Unless you changed the webpage code, you should find the same thing every day, and when things appear (surprise!) without your direct knowledge and action, you may want to review your security procedures.
Avatar of duncanb7
duncanb7

ASKER

Thanks for reply and article. And before this post, just think node.js is javascript complier  to compiler javascript code at server side, and ask myself  why my node.js will have  http access module feature if server has http access feature already.  After thinking around , the node.js might be useful for data communcation between  shell application and browser through http  or process access and based on javascript coding. it is similar or  sort of the way for adobe flash communcation between flash runtime process (installed on our window) and  browser.

For run command on browser, ActiveXObject is useful only on IE and but need to users to set all browser enable setting and that is NOT allowed on other browsers except using  its additional  add-on


Duncan
I think your analogy about Flash is quite apt.
ActiveXObject is useful only on IE
Right.  jQuery AJAX gives us cross-browser support.  This article illustrates the "hello world."
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
jquery.ajax is communcation between  server and client browser. How is it related to "run window command on browser on the same computer " ? Could you advise more ?

Duncan
I may be misunderstanding the question.  Is there a client/server relationship between the browser and the windows computer?  It's not uncommon for us to set up a web server on a laptop, develop PHP scripts on the laptop and test them via the locally-installed web server.  There is no internet connection involved, but the protocols are still the same.
Ray, thanks for your reply and reveiw
My question is  posted previously with title of  "run window command on browser with javascript and its concept" and with the three questions.

I have done one node.js testing in mins ago  where node.js is running on my command cmd.exe shell in which it will listen port 8000 for http request and then run notepad.exe (window command or application)  if http request is triggered, and I go to type my computer IP with port 8000  on browse at the same computer , the notepad.exe is triggered on the same computer. That is what I want to know, and the  answer to this thread YES, if we can install node.js on the same computer as browser. In other words, we can trigger window command execution through client-side ajax.

The testing  is similar to    Java and flash run-time installed  on our client computer which can make communication between window system and browser so that we can run java or flash application on browser.

You agree it  ?

In other method, I can convert node.js as window object library and let browser to call for window and browser communication

Please advise

Duncan
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although, the answer is not exactly to my question answer . But it triggered me to think again server and client role and jquery.ajax role, and  so that I  think server and client  could be on the same computer not just on different computers

thanks for your replies

Duncan
Thanks for the points.  Glad the dialog was helpful!