Calling CMD command line from ReactJS application

Viewed 2325

I have a React Application and I'm looking to run a CMD Command-Line function from a button click. What is the best way of doing this?

I am able to run the cmd command through a python script of my own however how could I run this python from React as React is hosted on localhost and security permissions limit access to cmd from there. Should I be looking to set up a python server to host the python script?

Alternatively, I have been looking at Node.js would that be a better way of running this python script and ultimately connect to cmd?

3 Answers

You need to configure a server side and use the child-process module import * as child from 'child_process'; then in your function use : child.exec("your command line")

React is working in the browser so it's impossible to directly access command line.

You just need to use the child-process module import * as child from 'child_process'; then in your function use : child.exec("your command line")

Related