【发布时间】:2015-04-30 13:07:41
【问题描述】:
我开发了一个 shell 脚本来重新连接我的路由器。
它适用于来自 GIT for Windows 的 Curl (Die curl-7.38.0-win64.msi) 和 sh.exe。
它在我的电脑上运行良好。
现在我想找到一种在我的 Android 设备上运行以下脚本的方法。 我已经成功安装了 Curl 但无法运行;它显示以下错误:
“错误:仅支持与位置无关的可执行文件 (PIE)。”
这与棒棒糖限制有关。是否可以通过其他方式(例如 Tasker、Restfull 或 Pythons Mechanize)来执行此操作?
#!/bin/sh
strindex() {
x="${1%%$2*}"
[[ $x = $1 ]] && echo -1 || echo ${#x}
}
curl 'http://easy.box/cgi-bin/login.exe' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: de-DE,de;q=0.8,en-GB;q=0.5,en;q=0.3' -H 'Connection: keep-alive' -H 'Host: easy.box' -H 'Referer: http://easy.box/' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0' -H 'Content-Type: application/x-www-form-urlencoded' -c cookies.txt --data 'pws=DEIN_PASSWORT' --location
sleep 6
reply=$(curl -b cookies.txt 'http://easy.box/cgi-bin/status_restart.exe' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: de,en-US;q=0.7,en;q=0.3' -H 'Connection: keep-alive' -H 'Host: easy.box' -H 'Referer: http://easy.box/main_status-and-support.stm#sub=restart' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0' --location)
sleep 6
echo $reply
sleep 1
#curl 'http://easy.box/login.stm'
index=$(strindex "$reply" "var _httoken")
echo $index
# we grab the first 40 letters...
tokenString=${reply:$index:40}
echo "Found TokenLine:$tokenString"
#strip start of string
tokenStringEnd=${tokenString##*= }
#strip end of string
token=${tokenStringEnd%%;*}
echo "Extracted token:$token"
echo "Sending reconnect command..."
curl -b cookies.txt 'http://easy.box/cgi-bin/status_restart.exe' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: de,en-US;q=0.7,en;q=0.3' -H 'Connection: keep-alive' -H 'Host: easy.box' -H 'Referer: http://easy.box/main_status-and-support.stm#sub=restart' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0' --location --data "httoken=$token"
感谢您的回答、想法和解决方案!
【问题讨论】:
-
您是从curl.haxx.se/gknw.net/7.40.0/dist-android/… 还是从其他地方获得了适用于 Android 的 curl?
-
不是来自 Play 商店的应用程序。这些 App 安装 cURL。在 Android 4.4 上它工作正常。如何安装 curl.haxx.se/gknw.net/7.40.0/dist-android/... 版本?