【发布时间】:2017-02-26 12:58:57
【问题描述】:
一切正常。但它给出了一个错误。我解决不了。
try.sh:
#!/bin/sh
website="http://lastofdead.xyz"
ipaddress=$( ifconfig | grep -v 'eth0:' | grep -A 1 'eth0' | \
tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)
mlicense=$(curl -s $website/lodscript/special/lisans.php?lisans)
if [ "$mlicense" = "$ipaddress" ];
then
echo "Positive"
else
echo "Negative"
fi
lisans.php:
<?php
if(isset($_GET['lisans'])) {
echo "188.166.92.168" . $_GET['lisans'];
}
?>
结果:
root@ubuntu:~# bash -x s.sh
+ website=http://lastofdead.xyz
++ cut -d ' ' -f 1
++ cut -d : -f 2
++ tail -1
++ grep -A 1 eth0
++ grep -v eth0:
++ ifconfig
+ ipaddress=188.166.92.168
++ curl -s 'http://lastofdead.xyz/lodscript/special/lisans.php?lisans'
+ mlicense=188.166.92.168
+ '[' 188.166.92.168 = 188.166.92.168 ']'
+ echo Negative
Negative
【问题讨论】:
-
也许尝试在您的条件下使用 -eq 运算符更改单个 = 并删除 " 字符?
-
@R.CanserYanbakan 我试过了,但是没用。
-
@R.CanserYanbakan 这些建议都不正确。
-
我个人会确认ip地址周围是否有空格
-
可能不相关,但
if [ "$mlicense" = "$ipaddress" ];将始终为真,分号不是必需的。