0

I'm looking for a type of string which triggers a command or javascript code w I try in my nodejs code something like these two

var x="<script>error: ${console.log('hi')}</script>"

or

var x="<script>error: ${reboot}</script>"

but they din't work. Is this possible at all or I'm wasting my time? Thanks

Nikos Kalantas
  • 95
  • 3
  • 11
  • No idea what you are trying to achieve. What is wrong with "just" `console.log(...)`? Where should what happen based on what information? – luk2302 Mar 04 '21 at 09:39
  • I'm trying to find out a string which will be able to trigger a command or a JavaScript. I know that console.log('...'); will do the job but i want this to be triggered from the string when its assigned in this variable – Nikos Kalantas Mar 04 '21 at 09:41

1 Answers1

-1

As you have mentioned Node.js

You can use exec from Node.js core module child_process like below

const { exec } = require("child_process");
exec('open -a Terminal .');

Or

If you want to run a node module

cp.exec('node path/to/file', (err, data, stderr) => {
    if (err) console.log(stderr);
    console.log(data); // spit out the data returned form the process
});

Note

But if you try to run this as a script in the browser it will not work as child_process module is not available in the browser environment.