2014-12-07 28 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/

这样就没有必要设置和取消代理一遍又一遍;它的速度也很快。