0

我试图uhttpd server在安装时运行Cgi-Cpp 程序OpenWRT。Cgi 文件是/www/cgi-bin/sample.cgi并且也具有执行权限。我正在尝试使用 HTML 文件访问此 Cgi。这是我的sample.cgi文件:

#include <iostream>
#include <vector>  
#include <string>  
#include <stdio.h>  
#include <stdlib.h> 

#include <cgicc/CgiDefs.h> 
#include <cgicc/Cgicc.h> 
#include <cgicc/HTTPHTMLHeader.h> 
#include <cgicc/HTMLClasses.h>  

using namespace std;
using namespace cgicc;

int main () {
   Cgicc formData;

   cout << "Content-type:text/html\r\n\r\n";
   cout << "<html>\n";
   cout << "<head>\n";
   cout << "<title>Using GET and POST Methods</title>\n";
   cout << "</head>\n";
   cout << "<body>\n";

   form_iterator fi = formData.getElement("first_name");  

   if( !fi->isEmpty() && fi != (*formData).end()) {  
      cout << "First name: " << **fi << endl;  
   }else{
      cout << "No text entered for first name" << endl;  
   }
   cout << "</body>\n";
   cout << "</html>\n";

   return 0;
} 

单击 HTML 中的提交按钮时出现错误:

unable to launch the requested CGI program: /www/cgi-bin/sample.cgi: Exec error

我错过了什么?所有权限都设置在那里。有什么建议么?

4

2 回答 2

2

确保您正在正确构建程序。首先打开一个终端窗口并 cd 到 /www/cgi-bin。现在使用

ls -l 

列出目录中的程序。您应该在那里看到您的 sample.cpp 文件。如果它不在那里,请将其移到那里。如果您不再有 sample.cpp 文件,请使用您最初发布的代码创建一个文本文件。您可以使用 nano 之类的文本编辑器来完成此操作。

nano sample.cpp

键入或粘贴到您的源文件中。然后按 ctrl-x 保存并退出程序。确保告诉 nano 保存程序而不是退出。

接下来删除现有的 sample.cgi。不要删除 sample.cpp。

使用此命令将源代码 (sample.cpp) 构建为二进制可执行文件:

g++ sample.cpp -o sample.cgi

“-o”是字母“o”,而不是数字“0”。如果构建引发编译错误,请修复错误并重复,直到成功构建程序。您现在将拥有一个二进制文件“sample.cgi”。

确保“sample.cgi”是可执行的。如果不是,则使其可执行

sudo chmod a+x sample.cgi

确保您可以先从命令行执行 sample.cgi。如果你不能这样做,那么服务器也不能这样做。然后输入

"./sample.cgi". 

执行应用程序后,您应该会在终端窗口中看到从应用程序发送的 html。

如果您需要进一步的帮助,请告诉我们。

于 2017-04-16T18:51:39.910 回答
1

如果您尝试制作表单,则使用 shell 脚本,然后使用 c++。在这里,我向您展示了我如何创建一个文件,在该文件中路由器可以设置为任何模式,如 dhcp、pppoe 或静态。

#!/bin/sh

echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '</head>'
echo '<br><h1><center>Welcome to Internet Service</center></h1>'

if [ -z "$QUERY_STRING" ]; then
    ssi=$(uci get wireless.@wifi-iface[1].ssid)
    key=$(uci get wireless.@wifi-iface[1].key)
    net=$(uci get network.wan.netmask)
    ipa=$(uci get network.wan.ipaddr)
    lip=$(uci -P /var/state get network.lan.ipaddr)
    ppu=$(uci get network.wan.username)
    ppp=$(uci get network.wan.password)
    ser=$(uci get network.wan.service)
    gat=$(uci get network.wan.gateway)
    rad=$(uci get network.wan.proto)
else
 # No looping this time, just extract the data you are looking for with sed:
 rad=`echo "$QUERY_STRING" | sed -n 's/^.*val_a=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ssi=`echo "$QUERY_STRING" | sed -n 's/^.*val_b=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 key=`echo "$QUERY_STRING" | sed -n 's/^.*val_c=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 lip=`echo "$QUERY_STRING" | sed -n 's/^.*val_j=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`     
 net=`echo "$QUERY_STRING" | sed -n 's/^.*val_d=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ipa=`echo "$QUERY_STRING" | sed -n 's/^.*val_e=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 gat=`echo "$QUERY_STRING" | sed -n 's/^.*val_f=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ppu=`echo "$QUERY_STRING" | sed -n 's/^.*val_g=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ppp=`echo "$QUERY_STRING" | sed -n 's/^.*val_h=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ser=`echo "$QUERY_STRING" | sed -n 's/^.*val_i=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
fi

echo '<body>'
echo "<form method=GET action=\"${SCRIPT}\">"
if [ $rad = "dhcp" ]; then
echo "<center><input type="radio" name="val_a" value="dhcp" checked> DHCP"\
  '<input type="radio" name="val_a" value="static"> Static'\
  '<input type="radio" name="val_a" value="pppoe"> PPPoE</center><br>'
elif [ $rad = "static" ]; then
echo "<center><input type="radio" name="val_a" value="dhcp"> DHCP"\
    '<input type="radio" name="val_a" value="static" checked> Static'\
    '<input type="radio" name="val_a" value="pppoe"> PPPoE</center><br>'
else
echo "<center><input type="radio" name="val_a" value="dhcp"> DHCP"\
  '<input type="radio" name="val_a" value="static"> Static'\
  '<input type="radio" name="val_a" value="pppoe" checked> PPPoE</center>                    <br>'
fi
echo "<table nowrap align="center">"\
  '<tr><td>           SSID:</TD><TD><INPUT type="textarea" rows=1 name="val_b" size=12 value="'$ssi'" autofocus></td></tr>'\
  '<tr><td>  WiFi Password:</td><td><INPUT type="textarea" rows=1 name="val_c" size=12 value="'$key'" maxlength="16" minlength="8"></td></tr>'\
  '<table nowrap align="center">'\
  '<center>(Password should be of 8 characters)</center>'\
  '<tr><td><br> LAN IPaddress:</td><td><br><INPUT type="textarea" rows=1 name="val_j" size=12 value="'$lip'"></td></tr>'\
  '<table nowrap align="center" style="border:2px solid;" cellspacing="5" cellpadding="5"><caption>Static Settings:-</caption>'\
  '<tr><td>    Subnet Mask:</td><td><INPUT type="textarea" rows=1 name="val_d" size=12 value="'$net'"></td></tr>'\
  '<tr><td>      IPaddress:</td><td><INPUT type="textarea" rows=1 name="val_e" size=12 value="'$ipa'"></td></tr>'\
  '<tr><td>Default Gateway:</td><td><INPUT type="textarea" rows=1 name="val_f" size=12 value="'$gat'"></td></tr><br>'\
  '<table nowrap align="center" style="border:2px solid;" cellspacing="5" cellpadding="5"><caption>PPPoE Settings:-</caption>'\
  '<tr><td> PPPoE Username:</TD><TD><INPUT type="textarea" rows=1 name="val_g" size=12 value="'$ppu'"></td></tr>'\
  '<tr><td> PPPoE Password:</TD><TD><INPUT type="textarea" rows=1 name="val_h" size=12 value="'$ppp'"></td></tr>'\
  '<tr><td>   Service Name:</TD><TD><INPUT type="textarea" rows=1 name="val_i" size=12 value="'$ser'"></td></tr><br>'\
  '</table></table></table>'

echo '<center><br><input type="submit" style="width:80px;height:35px;" value="Save"></form>'

# Make sure we have been invoked properly.
if [ "$REQUEST_METHOD" != "GET" ]; then
    echo "<hr>Script Error:"\
         "<br>Usage error, cannot complete request, REQUEST_METHOD!=GET."\
         "<br>Check your FORM declaration and be sure to use METHOD=\"GET\".<hr>"
    exit 1
fi
# If no search arguments, exit gracefully now.
if [ -z "$QUERY_STRING" ]; then
    exit 0
else
 # No looping this time, just extract the data you are looking for with sed:
 rad=`echo "$QUERY_STRING" | sed -n 's/^.*val_a=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ssi=`echo "$QUERY_STRING" | sed -n 's/^.*val_b=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 key=`echo "$QUERY_STRING" | sed -n 's/^.*val_c=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 lip=`echo "$QUERY_STRING" | sed -n 's/^.*val_j=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`     
 net=`echo "$QUERY_STRING" | sed -n 's/^.*val_d=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ipa=`echo "$QUERY_STRING" | sed -n 's/^.*val_e=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 gat=`echo "$QUERY_STRING" | sed -n 's/^.*val_f=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ppu=`echo "$QUERY_STRING" | sed -n 's/^.*val_g=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ppp=`echo "$QUERY_STRING" | sed -n 's/^.*val_h=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`
 ser=`echo "$QUERY_STRING" | sed -n 's/^.*val_i=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" | sed "s/%40/@/g" | sed "s/%28/(/g" | sed "s/%29/)/g" | sed "s/%25/%/g" | sed "s/%2B/+/g" | sed "s/%23/#/g" | sed "s/%21/!/g" | sed "s/%24/$/g" | sed "s/%5E/^/g" | sed "s/%3D/=/g" | sed "s/%7E/~/g" | sed "s/%7C/|/g" | sed "s/%7B/{/g" | sed "s/%7D/}/g" | sed "s/%5B/[/g" | sed "s/%5D/]/g" | sed "s/%3A/:/g" | sed "s/%3B/;/g" | sed "s/%3F/?/g" | sed "s/%2C/,/g" | sed "s/%3C/</g" | sed "s/%3E/>/g"`

 t1=$(ifdown wan)
 t2=$(uci set wireless.@wifi-iface[1].ssid=$ssi)
 t3=$(uci set wireless.@wifi-iface[1].encryption=psk2)
 t4=$(uci set wireless.@wifi-iface[1].key=$key)
 t5=$(uci commit wireless)
 t5=$(ifup wan)
 t6=$(wifi)
 t16=$(uci set network.lan.ipaddr=$lip)
 t7=$(uci set network.wan.proto=$rad)
 t8=$(uci set network.wan.username=$ppu)
 t9=$(uci set network.wan.password=$ppp)
 t10=$(uci set network.wan.service=$ser)
 t11=$(uci set network.wan.netmask=$net)
 t12=$(uci set network.wan.ipaddr=$ipa)
 t13=$(uci set network.wan.gateway=$gat)
 t14=$(uci commit network)
 t15=$(/etc/init.d/network restart)
fi

echo '</body>'
echo '</html>'
exit 0

只需从 html 调用此文件,它将在任何浏览器中打开。
注意:- 给这个文件 777 权限,不要给这个文件任何扩展名。只需通过给出它的名称来保存它。

于 2017-04-13T10:32:02.110 回答