特定のアカウントID「appid」とpasswd「passx」からのみアクセスできるファイルにテキストを追加したい次のコードを試しましたが、機能しません。
import os, subprocess
text=str('23.33%')
cmd = ['su', 'appid', '-c echo text >> /tofhisfile.txt']
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.communicate('passx')
また、これは機能しません
os.system('su appid -c echo text >> /tothisfile.txt')