使用Python子进程的whiptail

时间:2015-08-31 16:46:21

标签: python subprocess popen whiptail

我正在执行此处提到的以下白名单命令WhipTail Example

Mon Aug 31 2015 18:40:06 GMT+0200 (Stredoeurópsky čas (letný))

Python代码:

whiptail --title "Check list example" --checklist \
"Choose user's permissions" 20 78 4 \
"NET_OUTBOUND" "Allow connections to other hosts" ON \
"NET_INBOUND" "Allow connections from other hosts" OFF \
"LOCAL_MOUNT" "Allow mounting of local devices" OFF \
"REMOTE_MOUNT" "Allow mounting of remote devices" OFF

它不起作用。你能否告诉我哪里出错了。

错误消息。 whiptail的标准错误消息。

   cmd = ['whiptail', '--title', "Check list example", '--checklist', "Choose user's permissions", '20', '78', '4',
        " NET_OUTBOUND", " Allow connections to other hosts", "ON",
        " NET_INBOUND", " Allow connections from other hosts", "OFF",
        " LOCAL_MOUNT", " Allow mounting of local devices", "OFF"
        " REMOTE_MOUNT", " Allow mounting of remote devices", "OFF"]

   p = subprocess.Popen(cmd)
   p.communicate()

1 个答案:

答案 0 :(得分:1)

你在线上缺少逗号:

" LOCAL_MOUNT", " Allow mounting of local devices", "OFF",

正如@BrianCain所说,在将字符串转换为参数列表时,shlex.split是你的同志。