Bash 脚本中的命令输出到下拉框? [英] Output of command in Bash script to Drop-down box?

查看:27
本文介绍了Bash 脚本中的命令输出到下拉框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我感谢在回答这个问题时提供的任何帮助.我在 bash 脚本中有一个命令,它将输出以下内容:

First off, I appreciate any and all help in answering this question. I have a command in a bash script that will output the following:

255 254 253 252 ... 7 6 5 4 3 2 1 

这是一个特定的数字列表,从最大的(这是我想要的)开始,然后是最小的.数据集以空格分隔.上面的输出(包括所有数字除外)是您在 linux 机器上的终端中或通过 bash 脚本运行此命令时会看到的内容.

It is a specific list of numbers, beginning with the largest (which is what I would like), then going to the smallest. The dataset is space-delimited. The output above (except including all numbers), is what you would see if you ran this command in the terminal on a linux machine, or through a bash script.

我已将我的 apache2 服务器配置为允许通过 cgi-bin 目录使用 cgi/bash.当我在网上的 bash 文件中运行这个命令时,我得到了预期的输出.

I have configured my apache2 server to allow for cgi/bash through the cgi-bin directory. When I run this command in a bash file from the web, I get the expected output.

我正在寻找一种方法,能够将这些数字作为单独的条目放入下拉框中进行选择,这意味着用户可以从中选择一个数据点(例如 254)下拉菜单.

What I'm looking for is for a way to be able to put these numbers each as a separate entry in a drop-down box for selection, meaning the user can select one point of data (254, for example) from the drop down menu.

我不确定我在做什么,所以任何帮助将不胜感激.我不确定是否需要将数据转换为数组,或者什么.下拉菜单可以在 bash 脚本的同一页面上,但无论它在哪里,每次运行时都必须从命令更新它的数字列表.

I'm not sure what I'm doing with this, so any help would be appreciated. I'm not sure if I need to convert the data into an array, or what. The drop down menu can be on the same page of the bash script, but wherever it is, it has to update it's list of numbers from the command every time it is run.

感谢您的帮助.

推荐答案

我一直发现这个站点在摆弄 shell 脚本时很有用:http://tldp.org/LDP/abs/html/

I've always found this site useful when fiddling with shell scripts: http://tldp.org/LDP/abs/html/

您必须使用某种使用空格作为分隔符的字符串操作将输出放入数组中,然后循环遍历以构建一些 html 输出 - 因此返回值基本上只会在页面上输出您的选择框执行 cgi/bash 脚本的地方.

you'll have to get your output into an array using some sort of string manipulation using the spaces as delimiters, then loop over that to build some html output - so the return value will basically just output your select box on the page where you execute your cgi/bash script.

-肖恩

这篇关于Bash 脚本中的命令输出到下拉框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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