[英]Subprocess change folder permission on Picloud (an AMAZON EC2 server)?
In Ubuntu, I use subprocess.Popen
to call an executable file, which will save some output files on the hard drive of server (Picloud). 在Ubuntu中,我使用subprocess.Popen
调用可执行文件,它将一些输出文件保存在服务器(Picloud)的硬盘上。 The code has been tested successfully on a Local Ubuntu machine. 该代码已在本地Ubuntu计算机上成功测试。 However, it does not work on the server. 但是,它在服务器上不起作用。 My approach is listed below: 我的方法如下:
#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.
I am not sure why subprocess changes my folder permission on the server end. 我不确定为什么子进程会更改服务器端的文件夹权限。 So I try to use sudo
mode as: subprocess.Popen("sudo", "a.exe") As I expected, this code work locally only. 因此,我尝试将sudo
模式用作:subprocess.Popen(“ sudo”,“ a.exe”)如我所料,此代码仅在本地工作。
So can anyone give me some help on why subprocess will remove my write permission? 那么,谁能为我提供一些有关子进程为何会删除我的写许可权的帮助?
Thanks! 谢谢!
在Windows中,可以使用以下命令运行它:
subprocess.Popen("runas /user:Admin a.exe")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.