简体   繁体   中英

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). The code has been tested successfully on a Local Ubuntu machine. 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.

So can anyone give me some help on why subprocess will remove my write permission?

Thanks!

在Windows中,可以使用以下命令运行它:

subprocess.Popen("runas /user:Admin a.exe")

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.

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