2

I am attempting to use Javascript / NodeJS to build a new command line / terminal for personal use but I am running into some issues. I can't not seem to find a decent way of interacting with the windows command line from my own Javascript.

I understand that by default browsers do not allow javascript to interact with system based commands so I was considering using socketIO or something of the sort.

I was planning on using Electron (chromium).

I'm wondering what would be a good direction to pull the windows command line env into my window.

In all honesty, even just taking the existing output from the CMD would be a good enough start.

WeeniehuahuaXD
  • 852
  • 3
  • 10
  • 30
  • Are you asking how to perform console IO from NodeJs running on windows? OR how to write a console application using NodeJs while parsing the arguments? Your question is a little confusing, which is probably why you were downvoted (or maybe it was becase you didn't provide any examples of things you have tried) – akaphenom Apr 16 '16 at 16:38
  • Have you read anything like this: https://docs.nodejitsu.com/articles/command-line/how-to-prompt-for-command-line-input – akaphenom Apr 16 '16 at 16:39
  • I am seeking to build out essentially a terminal emulator that owrks with windows. There are plenty of options in other languages. But I want to be able to interact with the windows command prompt / env from a client facing application written in JS. – WeeniehuahuaXD Apr 16 '16 at 16:41
  • Have you seen somethign like this: http://stackoverflow.com/questions/15919347/how-to-execute-windows-shell-commands-cmd-exe-with-node-js – akaphenom Apr 16 '16 at 18:46
  • Hyperjs, Xtermjs, ShellJs for ui stuff, then use node child process – Aniket Jha Mar 15 '20 at 12:35

1 Answers1

2

In a Windows console window you can execute a JavaScript script using the command "cscript". It has been a while since I have done that so I was reviewing my previous work.

I know nothing about NodeJS but as I was searching for help to refresh my memory, I found several articles and StackOverflow answers that seem relevant. I hope these help.

Command Line JavaScript

How do I prompt users for input from a command-line script? - docs.nodejitsu.com

How to Read from stdin in JavaScript

node.js - How to read from stdin line by line in Node - Stack Overflow

Community
  • 1
  • 1
Sam Hobbs
  • 2,594
  • 3
  • 21
  • 32