setip.php :
setip.php:
<?php
$IP_Addr = $_GET['ip'];
$NetMask = $_GET['ip2'];
$NetWork = $_GET['ip3'];
$Broad = $_GET['ip4'];
$DNS = $_GET['dns1'];
$cmd="sh /var/www/cgi-bin/ipset.sh ".escapeshellarg($IP_Addr)."".escapeshellarg($NetMask)."".escapeshellarg($NetWork)."".escapeshellarg($Broad)."".escapeshellarg($DNS);
exec("$cmd");
example input : ip=10, ip2=20, ip3=30, ip4=40, dns1=10
示例输入:ip = 10,ip2 = 20,ip3 = 30,ip4 = 40,dns1 = 10
ipset.sh :
ipset.sh:
#!/bin/bash -x
echo "IPADDR=$1" >>/etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=$2" >>/etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETWORK=$3" >>/etc/sysconfig/network-scripts/ifcfg-eth0
echo "Broadcast=$4" >>/etc/sysconfig/network-scripts/ifcfg-eth0
echo "DNS=$5" >>/etc/sysconfig/network-scripts/ifcfg-eth0
result in ifcfg-eth0 :
导致ifcfg-eth0:
IPADDR=1020304010
NETMASK=
NETWORK=
BROADCAST=
DNS=
any sugestion how to pass argument correctly ?
任何消化如何正确传递参数?
1 个解决方案
#1
1
Solved, add space between argument.
解决了,在参数之间添加空格。
<?php
$IP_Addr = $_GET['ip'];
$NetMask = $_GET['ip2'];
$NetWork = $_GET['ip3'];
$Broad = $_GET['ip4'];
$DNS = $_GET['dns1'];
$cmd="sh /var/www/cgi-bin/ipset.sh ".escapeshellarg($IP_Addr)." ".escapeshellarg($NetMask)." ".escapeshellarg($NetWork)." ".escapeshellarg($Broad)." ".escapeshellarg($DNS);
exec("$cmd");
#1
1
Solved, add space between argument.
解决了,在参数之间添加空格。
<?php
$IP_Addr = $_GET['ip'];
$NetMask = $_GET['ip2'];
$NetWork = $_GET['ip3'];
$Broad = $_GET['ip4'];
$DNS = $_GET['dns1'];
$cmd="sh /var/www/cgi-bin/ipset.sh ".escapeshellarg($IP_Addr)." ".escapeshellarg($NetMask)." ".escapeshellarg($NetWork)." ".escapeshellarg($Broad)." ".escapeshellarg($DNS);
exec("$cmd");