英文:
Starting a program in screen (linux) using golang
问题
我想在一个使用os/exec库的golang项目中,在Linux上启动一个.exe文件。
我通常使用"mono"来启动.exe文件,所以我做了以下操作:
command := make([]string, 7)
command = []string{"screen", "-S", screenName, "-d", "-m", "mono", exeFile}
cmd := exec.Command(command[0], command[1:]...)
cmd.Dir = "ConsoleClient"
_, err := cmd.Output() //*
我无法运行这个命令,我也尝试过使用cmd.Run()
或cmd.Start()
。
*使用cmd.Start()
(对我来说是最好的方法),我没有看到任何错误,但最终没有创建screen。
我还尝试在我的命令末尾添加^M
,但仍然失败。
英文:
I want to start a .exe file in linux inside a golang project using os/exec library.
I usually use "mono" to start .exe file so i did:
command := make([]string, 7)
command = {"screen", "-S", screenName, "-d", "-m", "mono", exeFile}
cmd := exec.Command(command[0], command[1:]...)
cmd.Dir = "ConsoleClient"
_, err := cmd.Output() //*
I cant run this and i tried also with cmd.Run()
or cmd.Start()
*With cmd.Start()
(for me the best way) i don't see any error but at the end screen isn't created
It failed also adding ^M
at the end of my command
答案1
得分: 0
尝试将第2行改为以下内容:
command = {"screen", "-dmS", screenName, "mono", exeFile}
参数应该在屏幕名称之前。
英文:
Try this at line 2:
command = {"screen", "-dmS", screenName, "mono", exeFile}
parameters should be before the screen name.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论