使用鞭尾与Python子进程



我正在执行下面这里提到的whittail命令WhipTail示例

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 

您在行中缺少逗号:

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

正如@BrianCain指出的那样。在将字符串转换为参数列表时,Split是您的伙伴。

相关内容

  • 没有找到相关文章

最新更新