我想將我的變量從raw_input
傳遞給我的子進程命令。我是Python的新手。任何幫助,他會感激。將變量傳遞給子進程調用
#!/usr/bin/python
import subprocess
print "\nWhat user name"
username = str(raw_input('username: '))
print "\nWhat is the user id"
userid = int(raw_input('Enter user id: '))
print "\nWhat is the user\'s primary group?"
primarygroup = int(raw_input('Enter group: '))
print "\nWhat is the user\'s secondary group?"
secondarygroup = int(raw_input('Enter group: '))
subprocess.call(['useradd' '-m' '-g' _primarygroup '-G' _secondarygroup '-u' _userid _username])
print"\nThe user has been added"
你有什麼問題?請具體說明。 – 2011-01-25 15:19:19
「具體」是 - 希望 - 讓n00bz更清楚地思考他們的問題。 – 2011-01-25 16:04:04
真的很古老,但我會注意到,例如,主要羣組被讀入`primarygroup`,但隨後嘗試通過`_primarygroup`訪問。 – altendky 2017-09-15 12:55:33