赞
踩
首先安装apache服务
yum -y install httpd
如下介绍两种执行的方式
- #cat /var/www/cgi-bin/shell
- #!/bin/sh
- printf "Content-Type: text/plain\n\n"
- your_commands_here
传参的动作
- http://172.16.61.119:8098/cgi-bin/shell?pwd
-
- 在浏览器里访问这个url就可以显示pwd路径
首先准备index.html的页面
- #cat /var/www/html/index.html
- <html>
- <head>
- <script>
- function httpGet(url)
- {
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.open("GET", url, false); // false: wait respond
- xmlHttp.send(null);
- return xmlHttp.responseText;
- }
- function f()
- {
- var url = "http://172.16.61.119:8098/cgi-bin/shell?wanyan%20"+ document.getElementById('in').value;
- document.getElementById('out').innerHTML = httpGet(url);
- }
- </script>
- </head>
- <body>
- <span>专营店授权代码: </span>
- <input id='in'></input>
- <button onclick='f()'>提交查询</button>
- <br/>
- <pre id='out'></pre>
- </body>
- </html>
index.html页面注释:
shell文件的内容(这里需要变更shell里的内容和直接传参的方式内容是不相同的)
- #cat /var/www/cgi-bin/shell
- #!/bin/sh
- alias urldecode='sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b"'
- echo -e "Content-type: text/plain\n"
- decoded_str=`echo $QUERY_STRING | urldecode`
- echo -e "`$decoded_str` \n"
自定义脚本内容
- #cat /usr/local/bin/wanyan
- #!/bin/bash
- CODE=$1
- curl -X POST "http://172.16.61.223:8716/bi/globe/api/queryCustomer" -H "Request-Origion:SwaggerBootstrapUi" -H "accept:application/json" -H "token:" -H "Content-Type:application/json" -d "$CODE" |jq|grep -E 'authCode|cloudShopName|shopAddress|yestaeCustomerManagerName|cloudShopAdminName|cloudShopAdminMobile|shopOwner|ownerMobile|shopLevelName'|sed --expression='s/"//g' --expression='s/,//g' --expression='s/ //g'
wanyan这个脚本注释
最终的页面展示的效果
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。