metadata Posted September 13, 2012 Share Posted September 13, 2012 Hello, I am working on a project in which I need to out put text to the command line, as well as prompt for input from the command line. The application is to use JS and I'm looking for some reference materials on pulling this off. Any info is appreciated. Thanks! Link to comment Share on other sites More sharing options...
thescientist Posted September 13, 2012 Share Posted September 13, 2012 Are you using Node.js? if you're trying to do this from a browser that's not going to happen. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2012 Share Posted September 13, 2012 Are you referring to the operating system's shell when you say command line? Link to comment Share on other sites More sharing options...
metadata Posted September 13, 2012 Author Share Posted September 13, 2012 Are you using Node.js? if you're trying to do this from a browser that's not going to happen. No it's not being done through the browser, it's more of a test application than a functional one. From the command line in Windows I'm using the cscript //nologo file.js command to run the application. I'm going to output the interactions within the file.js to a xml doc as a log eventually. Link to comment Share on other sites More sharing options...
metadata Posted September 13, 2012 Author Share Posted September 13, 2012 Are you referring to the operating system's shell when you say command line? yes Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2012 Share Posted September 13, 2012 Javascript running in a browser can't interact directly with the operating system. If you're just doing this for yourself then you can use ActiveX components, which are only supported by IE, and you'll probably need to set special permissions for your page to allow it to happen. http://www.itjungle.com/mpo/mpo052302-story01.html Link to comment Share on other sites More sharing options...
metadata Posted September 13, 2012 Author Share Posted September 13, 2012 Is there a way to execute a js file without a browser? I'm talking straight from the Windows shell. Again this is for my use only, not to be used on a website or in conjunction with any kind of html. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2012 Share Posted September 13, 2012 Yes, the Windows Script Host can execute Javascript code. Link to comment Share on other sites More sharing options...
metadata Posted September 13, 2012 Author Share Posted September 13, 2012 (edited) OK, so how do output back to that command line? For instance this block of code will output to an html doc, and then to the browser, for a user to see.... var prompt = "Hello, this is x calling."; //output prompt function S_Hello(prompt){ return prompt; } document.write(S_Hello); However, I need code to output right to that command line/shell for the user to see the output and then enter in more further on in the program. Edited September 13, 2012 by metadata Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2012 Share Posted September 13, 2012 I've never used WSH to try and write an interactive application, I can't really answer that question. There is probably a better tool to use than Javascript. You may want to look into Powershell. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now