im trying to execute the folowing with nodejs with Windows
var exec = require('child_process').exec;
var cp = exec('A:\Programme\node\node.exe',function(err,std,ste) {
console.log(err);
});
i tried replacing node with echo, ipconfig etc.. but i always get the same response:
{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
Im sure that I linked the PATH correctly and I have avoided Spaces.
Does someone have an idea where the Problem could be?
edit
Alright i got, some douchebag removed System32 from PATH.
Added it, now it runs again.
thx for the help.
Related
I'm trying to make a Discord bot that can shut down on command. Yesterday I asked another question related to this but no one answered. So now I'm thinking is there any way to stop ts-node-dev from command line / .ts file?
Have you tried process.exit(1)? It works in js. I think you need to install #types/node for ts?
Alternatively you can use a bit of a whacky method:
You can try launching ts-node with pm2 or nodemon and in order to kill your bot try executing cli command like
exec("killall nodemon", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
I hope it helps
Im running the following commands in array it works !
command: ["k6", "run", "/etc/config/load_test.js"]
Now when I add just
--compatibility-mode=base
I got error , I try it like this
command: ["k6", "run", "--compatibility-mode", "base", "/etc/config/load_test.js"]
Any idea what im doing wrong? https://k6.io/docs/testing-guides/running-large-tests#compatibility-mode=base
error: accept one arg(s) receive 2
if I pass it to to the terminal like this it works
k6 run --compatibility-mode=base someplace/myscript.es5.js
But not sure how to put it in array of args
I've tried also
command: ["k6", "run", "--compatibility-mode=base", "/etc/config/load_test.js"] which doesnt work either ...
Have you tried this one:
command: ["k6", "run", "--compatibility-mode=base", "/etc/config/load_test.js"]
command is running on CLI on Linux.
ffmpeg-concat -t circleopen -d 750 -o /var/www/html/testing_video/huzzah.mp4 /var/www/html/testing_video/1.mp4 /var/www/html/testing_video/2.mp4 /var/www/html/testing_video/3.mp4 2>&1
Perfectly working on CLI. But when i used with the shell_exec command from a php file it gives an error.
failed to create OpenGL context
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/context.js:24:11)
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/render-frames.js:19:21)
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/index.js:53:32)
at
Anyhow i debug the code function is calling and the parameters width and height is passing but still returning null.
Node version:v8.11.3
I have a node.js program running as a service on my windows PC which I use to open files. The only way I have found to make this work is to use node.js to open PSExec, as node doesn't appear to have the ability to open a program as another user (in windows).
The code below works, however it is somewhat insecure, as the username and password can be discovered by watching process monitor, or even the command line column in task manager. I don't store the password in the source by the way, just put it there to keep the example simple.
var EventLogger = require('node-windows').EventLogger;
var log = new EventLogger('File Launcher starting');
var exec = require('child_process').exec;
var userName = "mike";
var password= "mikesPassword";
var fullPath= "C:\folder\file.xls";
exec("PSExec.exe -accepteula -h -d -u "+userName+" -p "+password+" -i 1 C:\\WINDOWS\\SYSTEM32\\CMD.EXE /c start \"\" \""+fullPath+"\"",{cwd: process.cwd}, function(error, stdout, stderror) {
if(error){
log.error(stderror.replace('\n','').replace('\r',''));
}
if(stdout){
log.info(stdout.replace('\n','').replace('\r',''));
}
Is there some other way I can get node.js to launch a file as another user without exposing the username and password?
I attempted to do it using powershell, but it seems SYSTEM is not allowed to launch files as other users.
I have a php file which needs to be executed in CLI from my Php application which runs on CodeIgniter framework. I tried the exec and shell_exec command and it seems to not start the process. Please find the code below which I try to execute.
$phpPath = exec('which php');
$cmd = $phpPath.' '.dirname(__DIR__).'/API/notification/NotificationServer.php';
echo "<pre>".shell_exec($cmd)."</pre>";
When I try running the above in Terminal it executes fine. I need to automatically trigger this once the user has a session set.
The path/$cmd variable prints
when I print the variable $cmd i get the below output, and the below when given in terminal works fine.
/usr/bin/php /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php
the above command works fine in the Terminal. When i try to exec/shell_exec it, it is not working.
APACHE_ERROR LOGS ARE :
sh: line 1: 2437 Trace/BPT trap: 5 /usr/bin/php
sh: line 1: /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php: Permission denied
Can someone help me out in running this above code in CLI ?
I solved the problem, Guess there would be someone else like me trying to access the restricted folders. I found the solution here
http://ubuntuforums.org/showthread.php?t=1302259
exec('chmod +x'.dirname(__DIR__).'/API/notification/NotificationServer.php);
The above worked the magic.