From 4c88efb19f186c53c7b21cd638fe40ac04cac304 Mon Sep 17 00:00:00 2001 From: Zeno Zeng Date: Sat, 20 Sep 2014 18:20:13 +0800 Subject: [PATCH] add iconv for response in wlan.sh --- README.md | 10 ++++++---- wlan.sh | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fd91500..d04da25 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ Command Line Scripts for ZJU (VPN / WLAN / DNS) -## Require +## Requirements -```bash -sudo apt-get install curl -``` +### wlan + +- curl + +- xl2tpd ## TODO diff --git a/wlan.sh b/wlan.sh index c9e5516..b0d07aa 100755 --- a/wlan.sh +++ b/wlan.sh @@ -2,6 +2,8 @@ # wlan.sh -- login/logout for ZJUWLAN # +# Requirements: curl, iconv +# # Copyright (C) 2014 Zhang Hai # Copyright (C) 2014 Zeno Zeng # @@ -24,14 +26,14 @@ logout() { PASSWORD=$2 echo "Logout: ${USERNAME}" - RESPONSE=$(curl "https://net.zju.edu.cn/rad_online.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=auto_dm&username=${USERNAME}&password=${PASSWORD}" -s) + RESPONSE=$(curl "https://net.zju.edu.cn/rad_online.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=auto_dm&username=${USERNAME}&password=${PASSWORD}" -s | iconv -c -f gbk -t utf8) case "${RESPONSE}" in *ok*) echo "Logout: success." ;; *) - echo "Logout: ${RESPONSE}." + echo "Logout: ${RESPONSE}" exit 1; ;; esac @@ -44,7 +46,7 @@ login() { logout $USERNAME $PASSWORD echo "Login: ${USERNAME}" - RESPONSE=$(curl "https://net.zju.edu.cn/cgi-bin/srun_portal" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&type=1&is_ldap=1&local_auth=1" -s) + RESPONSE=$(curl "https://net.zju.edu.cn/cgi-bin/srun_portal" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&type=1&is_ldap=1&local_auth=1" -s | iconv -c -f gbk -t utf8) case "${RESPONSE}" in *help.html*)