2012-05-04 5 views
1

Ubuntuでは、私はsubprocess.Popenを使用して実行可能ファイルを呼び出します。これにより、サーバー(Picloud)のハードドライブにいくつかの出力ファイルが保存されます。このコードはLocal Ubuntuマシンで正常にテストされています。ただし、サーバー上では動作しません。私のアプローチは以下の通りです:Picloud(AMAZON EC2サーバー)のサブプロセス変更フォルダの許可?

#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モードを使用しようとします: subprocess.Popen( "sudo"、 "a.exe") 私の予想通り、このコードはローカルでのみ動作します。

誰かがサブプロセスが私の書き込み許可を取り除く理由について助けてくれますか?

ありがとうございます!

答えて

0

ウィンドウで、次のコマンドでそれを実行することができます。

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

は、Windows上でこの仕事をしていますか?少なくともLinuxでは、 'subprocess.Popen'の最初の引数はリストである必要があります.... – larsks

+0

Windowsではテストしていません。コードはローカルのubuntuマシンで動作しますが、サーバ側で同じコードが失敗しました。 –

関連する問題