在Ubuntu中,我使用subprocess.Popen
调用一个可执行文件,它将在服务器(Picloud)的硬盘上保存一些输出文件。代码已经在本地Ubuntu机器上成功地测试过。但是,它在服务器上不起作用。我的方法如下:
#create a new folder.
#The permission is drwxrwx--- both locally and on the server end
os.makedirs(folder)
#copy the executable file to this folder.
#The permission is drwxrwx--- both locally and on the server end after copy
shutil.copy("a.exe", folder)
#call this exe file.
#The permission is drwxrwx--- locally but changed to drwxr-x--- on the server end.
#Since I do not have the write permit, my code fails
subprocess.Popen("a.exe")
>>>OSError: [errno 13] permission denied.
我不知道为什么子进程更改了服务器端的文件夹权限。所以我尝试使用sudo
模式作为:
子流程.Popen(“sudo”,“a.exe”)
正如我所料,这个代码只在本地工作。在
那么有谁能帮我解释一下为什么子进程会删除我的写权限?在
谢谢!在
在windows中,可以使用以下命令运行它:
相关问题 更多 >
编程相关推荐