0

我正在执行WhipTail 示例中提到的以下 whitetail 命令

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

Python代码:

   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()

这没用。你能否建议我哪里出错了。

错误信息。鞭尾的标准错误消息。

Executing Command
Box options: 
    --msgbox <text> <height> <width>
    --yesno  <text> <height> <width>
    --infobox <text> <height> <width>
    --inputbox <text> <height> <width> [init] 
    --passwordbox <text> <height> <width> [init] 
    --textbox <file> <height> <width>
    --menu <text> <height> <width> <listheight> [tag item] ...
    --checklist <text> <height> <width> <listheight> [tag item status]...
    --radiolist <text> <height> <width> <listheight> [tag item status]...
    --gauge <text> <height> <width> <percent>
Options: (depend on box-option)
    --clear             clear screen on exit
    --defaultno         default no button
    --default-item <string>     set default string
    --fb, --fullbuttons     use full buttons
    --nocancel          no cancel button
    --yes-button <text>     set text of yes button
    --no-button <text>      set text of no button
    --ok-button <text>      set text of ok button
    --cancel-button <text>      set text of cancel button
    --noitem            don't display items
    --notags            don't display tags
    --separate-output       output one line at a time
    --output-fd <fd>        output to fd, not stdout
    --title <title>         display title
    --backtitle <backtitle>     display backtitle
    --scrolltext            force vertical scrollbars
    --topleft           put window in top-left corner
    -h, --help          print this message
    -v, --version           print version information 
4

1 回答 1

1

您在行中缺少逗号:

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

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

于 2015-08-31T17:03:52.167 回答