shell脚本作为cgi程序--以web版man为例
man.cgi源码
#! /bin/sh
eval `sh proccgi.sh $*`
echo "Content-type: text/html"
echo
echo
echo "<html>"
echo "<head>"
echo "<meta charset="UTF-8">"
echo "<title>shell-cgi实现man命令</title>"
echo "<style>"
echo "pre {margin:0 auto; width:"50%"; height:"100%"; font-size:12pt;}"
echo "</style>"
echo "</head>"
echo "<body>"
if man $FORM_command>/dev/null
then
echo "<pre>"
man $FORM_command
echo "</pre>"
else
echo "<p>对不起,没有查询到相关信息"
fi
echo "</body>"
echo "</html>"
html源码
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>man for web</title>
<link rel="stylesheet" type="text/css" href="man.css"/>
<script type="text/javascript">
window.onload=function()
{
var submit=document.getElementById("submit");
submit.onclick=function(){
if(document.myform.command.value==""){
alert("你没有输入任何信息");
return false;
}
}
}
</script>
</head>
<body>
<div id="box">
<h1>man for web</h1>
<form method="post" action="/cgi-bin/man.cgi" name="myform">
<input type="text" placeholder="命令" name="command"></input>
<button class="but" type="submit" id="submit">确定</button>
</form>
</div>
</body>
</html>
man.css源码
html{
width: 100%;
height: 100%;
overflow: hidden;
}
body{
width: 100%;
height: 100%;
margin: 0;
background-color: #4A374A;
}
#box{
position: absolute;
top: 50%;
left:50%;
margin: -150px 0 0 -150px;
width: 300px;
height: 300px;
}
#box h1{
color: #fff;
letter-spacing: 1px;
text-align: center;
}
h1{
font-size: 2em;
margin: 0.67em 0;
}
input{
width: 278px;
height: 18px;
margin-bottom: 10px;
outline: none;
padding: 10px;
font-size: 13px;
color: #fff;
border-top: 1px solid #312E3D;
border-left: 1px solid #312E3D;
border-right: 1px solid #312E3D;
border-bottom: 1px solid #56536A;
border-radius: 4px;
background-color: #2D2D3F;
}
.but{
width: 300px;
min-height: 20px;
display: block;
background-color: #4a77d4;
border: 1px solid #3762bc;
color: #fff;
padding: 9px 14px;
font-size: 15px;
line-height: normal;
border-radius: 5px;
margin: 0;
}
效果图

proccgi.sh是在网上很容易找到,就不贴出源码了。它的作用是取得post过来的数据。
参考链接:
http://www.jb51.net/web/458871.html
shell脚本作为cgi程序--以web版man为例的更多相关文章
- 读《Linux Shell脚本攻略》(第2版) 总结
前段时间读完了<Linux Shell脚本攻略>(第2版)这本书,给部分想读这本书的人分享下个人感受. 说下这本书的难度吧.纯新手或者只懂少部分编程知识的人,读起来还是有很大难度的.以我为 ...
- 读《Linux Shell脚本攻略》(第2版) 一遍、二遍体会
前段时间读完了<Linux Shell脚本攻略>(第2版)这本书,给部分想读这本书的人分享下个人感受. 第一遍体会解读:就像黑夜中的灯塔,指明前进的道路. 推荐指数:强烈推荐. 书中讲解的 ...
- IDEA部署项目,并结合Shell脚本运行Java程序
一.概述 在实际开发中,我们写好的代码,往往打成war包或jar包,通过winscp或其他软件将其上传至服务器,然而这样非常大的一个弊端就是不利于开发,为什么这么说呢?假如我们刚刚将springboo ...
- Linux简单Shell脚本监控MySQL、Apache Web和磁盘空间
Linux简单Shell脚本监控MySQL.Apache Web和磁盘空间 1. 目的或任务 当MySQL数据库.Apache Web服务器停止运行时,重新启动运行,并发送邮件通知: 当服务器磁盘的空 ...
- shell脚本--初识CGI
CGI按照百度百科的定义,如下: CGI 是Web 服务器运行时外部程序的规范,按CGI 编写的程序可以扩展服务器功能.CGI 应用程序能与浏览器进行交互,还可通过数据库API 与数据库服务器等外部数 ...
- 利用cgi编程实现web版man手册
董老师前几天给我们布置了3道作业,第三道作业是cgi程序设计. 题目: web服务器cgi接口功能的实现 要求: 能调用cgi程序并得到返回结果: cgi程序能接受参数并得到返回结果: 使用两种或以上 ...
- shell脚本运行java程序jar
在UBuntu上部署项目的时候,我们往往通过一段shell来启动程序,甚至是通过crontab定时任务来定时的调用java程序,但是很奇怪的一个问题就是,比如我写了一个如下的shell脚本: #!/b ...
- RDIFramework.NET V2.5(.NET快速信息化系统开发框架) Web版界面样例(可参考)
RDIFramework.NET V2.5(.NET快速信息化系统开发框架) Web版介绍 现已升级到V2.8,点击查看 B/S结构(Browser/Server,浏览器/服务器模式),是WEB兴起 ...
- shell脚本--编写CGI代码(shell结合html)以及环境变量
实现shell和html标签混合的方式编写代码: 推荐 初始CGI ,看完大概之后,大概对cgi有个大体的印象.下面是编写混合代码的示例: #!/bin/bash #index.cgi echo & ...
随机推荐
- 如何写一个优秀的GitHub项目README文档?
今天给大家介绍一个Github上的README文档写作教程模版,该模版目前获得6634颗星星,2296Fork,相对而言,还是比较得到大家认可的.不花哨,不别出心裁,一个比较实用的,普适性的架子:所谓 ...
- [LeetCode] 124. Binary Tree Maximum Path Sum_ Hard tag: DFS recursive, Divide and conquer
Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any ...
- 使用 nghttpx 搭建 HTTP/2 代理 (转)
来自http://www.fanyue.info/2015/08/nghttpx-http2.html 使用 nghttpx 搭建 HTTP/2 代理 [转] HTTP/1.1,定义于 1999 年, ...
- cocos2d-x JS 开启远程代码调试
为了方便服务端与测试部门的工作需要,把客户端的写的程序可以在其他电脑上运行,方便他人工作与测试. 下面是cocos2d-x JS WebStorm 的设置方法.
- Selenium基础知识(五)多窗口切换
说到多窗口切换必须想到driver.switch_to.window()方法 driver.switch_to.window() 实现在不同窗口之间切换 driver.current_window_h ...
- react native 中使用swiper
1.下载依赖 cnpm install react-native-swiper --save 2.在组件中使用 import React, { Component } from 'react'; im ...
- VS基本学习之(变量与常量)
一.变量与常量 1) 变量 由(定义+赋值+取值组成) 变量的命名规则: ① 变量名组成:字母 数字 下划线 @ 汉字 ② 首字母只能用:字母 下划线 @ 汉字(不能是数字 ...
- JS实例2
进度条 <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ...
- Vivado的安装程序没反应怎么办
在Windows操作系统上,在安装Vivado的时候会遇到双击xsetup.exe没有反应的情况,即使是用管理员权限再加上设置兼容模式也没有任何效果,且此问题有可能在多个版本上都存在,包括最新的201 ...
- ueditor上传图片配置成功,但是如何删除无用的图片
我使用ueditor作为富文本编辑器,配置已经好了,上传功能也好了.现在的问题是当使用ueditor上传图片的时候,选择了图片就立刻上传到指定的文件夹里,而后续即使没有保存该篇文章内容,即取消操作,图 ...