在bash动态对话框--menu箱 [英] Dynamic dialog --menu box in bash

查看:179
本文介绍了在bash动态对话框--menu箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找关于在bash使动态对话框--menu框很好的解释。我想从具有结构像这样的文件中加载用户的列表:

I'm searching for good explanation about making dynamic dialog --menu box in bash. I'm trying to load a list of users from a file that have structure like this:

------ user ------  
/rw412 0.2 /rx511 23.1 /sgo23 9.2  
/fs352 1.4 /...  
------ another_user ------
/rw412 0.3 / and so on...

当然,用户名是之间------ 结果
我真的不知道如何使用对话框里面循环。我也试图避免产生额外的文件。

of course the user name is between ------
i don't really know how to use loops inside dialog. I'm also trying to avoid creating additional files.

请帮忙

推荐答案

确定

继丹尼斯·威廉姆森的线索和我自己的想法我来到像这样

Following Dennis Williamson clues and my own ideas i came to something like this

#!/bin/bash
c=0
while read -r dashes1 username dashes2
do
  if [[ $dashes1 == --*-- && $dashes2 == --*-- ]]
  then
    options=("${options[@]}" "$((++c))" "$username")
  fi
done < inputfile
cmd=(dialog --backtitle "title" --menu "Select_user:" 22 38 2) #2 becouse 
i know there will be 2 options
command=`echo "${cmd[@]}" "${options[@]}" "2>file"`
$command

现在,有这样的错误:
错误:预期2个参数,只发现1

Now, there is an error like this: Error: Expected 2 arguments, found only 1.

这是为什么?

这篇关于在bash动态对话框--menu箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆