简体   繁体   English

如何在 Linux 托管 NodeJS 上打开 a.exe 文件

[英]How to open a .exe file on Linux Hosted NodeJS

I am attempting to have my node server launch a.exe file on a Linux hosted implementation of NODEJS我试图让我的节点服务器在 Linux 托管的 NODEJS 实现上启动 a.exe 文件

My.exe is located here: '/home/username/projects/ProjectName/server/webserver/Project.exe' My.exe 位于此处: '/home/username/projects/ProjectName/server/webserver/Project.exe'

and when I attempt to start the exe当我尝试启动 exe

with:和:

   exec('/home/username/projects/ProjectName/server/webserver/Project.exe', ["/home/username/projects/ProjectName/server/webserver/files/"+date], function(err, data) {
}

i am getting a file not fond error我收到一个文件不喜欢的错误

that looks like this:看起来像这样:

{ Error: Command failed: /home/username/projects/ProjectName/server/webserver/Project.exe /home/username/projects/ProjectName/server/webserver/files/31005
/home/username/projects/ProjectName/server/webserver/Project.exe: 1: /home/username/projects/ProjectName/server/webserver/Project.exe: MZ�##���@�#��: not found
/home/username/projects/ProjectName/server/webserver/Project.exe: 2: /home/username/projects/ProjectName/server/webserver/Project.exe: Syntax error: ")" unexpected

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:198:13)
    at Pipe._handle.close (net.js:606:12)
  killed: false,
  code: 2,
  signal: null,
  cmd:
   '/home/username/projects/ProjectName/server/webserver/Project.exe /home/username/projects/ProjectName/server/webserver/files/31005' }

When attempting to run the same function on a windows based NodeJS with windows directories instead of linux it works, the file can be opened via Wine on Linux, is there somewhere in my function call where i need to direct it to open the.exe with WINE? When attempting to run the same function on a windows based NodeJS with windows directories instead of linux it works, the file can be opened via Wine on Linux, is there somewhere in my function call where i need to direct it to open the.exe with葡萄酒? If so how do I go about doing that?如果是这样,我该怎么做?

Try this尝试这个

const { exec} = require('child_process');
 exec('wine /home/username/projects/ProjectName/server/webserver/Project.exe /home/username/projects/ProjectName/server/webserver/files/'+date,
function(err, data){

});

https://superuser.com/questions/1058985/launch-program-with-wine-using-exe-arguments https://stackoverflow.com/a/49069169/12167785 https://superuser.com/questions/1058985/launch-program-with-wine-using-exe-arguments https://stackoverflow.com/a/49069169/12167785

I got my desired functionality using the following:我使用以下方法获得了我想要的功能:

exec("wine", ["/home/username/projects/ProjectName/server/webserver/Project.exe", date], function(err,data){
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM