metadata 0 Posted September 13, 2012 Report 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! Quote Link to post Share on other sites
thescientist 231 Posted September 13, 2012 Report 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. Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 13, 2012 Report Share Posted September 13, 2012 Are you referring to the operating system's shell when you say command line? Quote Link to post Share on other sites
metadata 0 Posted September 13, 2012 Author Report 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. Quote Link to post Share on other sites
metadata 0 Posted September 13, 2012 Author Report Share Posted September 13, 2012 Are you referring to the operating system's shell when you say command line? yes Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 13, 2012 Report 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 Quote Link to post Share on other sites
metadata 0 Posted September 13, 2012 Author Report 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. Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 13, 2012 Report Share Posted September 13, 2012 Yes, the Windows Script Host can execute Javascript code. Quote Link to post Share on other sites
metadata 0 Posted September 13, 2012 Author Report 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 Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 13, 2012 Report 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.