Trying to run a cpp program through shell, using exec command in nodejs, I wrote below exec command in node.js. (btw i am trying in windows)
exec(`g++ ${fileData.filepath} -o ${outPath} && cd ${outputPath} && ./${jobId}.exe,
(error,stdout,stderr)=>{
if(error){
reject({error,stderr})
}
if(stderr){
reject(stderr)
}
resolve(stdout)
})
The Program is getting stored where it was expected to get stored in.exe format. There is one error which I am getting which is '.' is not recognized as an internal or external command, operable program or batch file. Help me fix this.
Just remove ./
from the exec command for executing the exe file, because ./ is used in linux, not in Windows ( When you are already in the directory containing the executable file ).
exec(`g++ ${fileData.filepath} -o ${outPath} && cd ${outputPath} && ${jobId}.exe`,
(error,stdout,stderr) => {...})
For an executable you don't need to do ./
. just filename.exe should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.