2014-12-07 63 views
0

很簡單:代理設置不起作用

我有:

Distributor ID: Ubuntu 
Description: Ubuntu 14.04.1 LTS 
Release: 14.04 
Codename: trusty 

我想通過慶典設置在Firefox代理:

#!/bin/bash 

IP="1.2.3.4" 
PORT="2200" 

grep -v "network.proxy.\(http\|http_port\|type\)" prefs.js > temp && mv temp prefs.js 

echo "user_pref(\"network.proxy.http\", \"$IP\")" >> prefs.js 
echo "user_pref(\"network.proxy.http_port\", $PORT)" >> prefs.js 
echo "user_pref(\"network.proxy.type\", 1)" >> prefs.js 

首選項。 js被相應地修改,但firefox不設置代理。看到包含的圖像。

enter image description here

我有完全相同的問題,使用此代碼:

cat <<EOT >> prefs.js 
user_pref("network.proxy.http", $IP); 
user_pref("network.proxy.http_port", $PORT); 
user_pref("network.proxy.type", 1); 
EOT 

非常感謝你的鄉親!

+0

帶貓<< EOT,應該是「$ IP」而不是$ IP,對於該錯字感到抱歉 – 2014-12-07 09:55:01

回答

0

實際上我發現了一個解決方案,在設置代理之前,我測試了它。 看到這樣的代碼:

result=`HEAD -d -p http://$IP:$PORT -t 20 www.any_url.com HTTP/1.1` 
if [ "$result" = "200 OK" ]; then 
    [do whatever you want...] 
    break; 
else 
    [do something else ...] 
fi 

done; 

看到http://snipplr.com/view/17899/http-proxy-checker/

這樣就沒有必要設置和取消代理一遍又一遍;它的速度也很快。