ファイルを削除してから、Pythonでファイルの名前を削除したファイルに変更しようとしています。
import sys
import subprocess
fileInput = sys.argv[1]
|
|
#code to create fileInput.tmp
|
|
ret=subprocess.Popen("rm "+fileInput,shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print ret
ret1=subprocess.Popen("mv "+ fileInput+".tmp "+fileInput,shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print ret1
発生しているのは、fileInputとfileInput.tmpの両方が"ret="
ステップで削除され、"ret1="
ステップが実行されない場合があります(常にではありません)。
誰かがなぜそれが幸せなのかを提案できますか?このコードはMacOSxで実行されます