6

I want to set system Proxy address through my Qt application. So i was wondering if i could write a script which can be executed by my application every time to change the proxy address.

I tried :

 #! /bin/sh 
 echo "# Generated by Application"

 export $1
 echo "Proxy Address ${1}

but this script was not successful. I think it was unable to execute "export" command.

Can anyone help me resolving this issue ?

10

Try this:

#! /bin/sh
echo "# Generated by Application"
export http_proxy='http://$1/'
export ftp_proxy='http://$1/'

Note:

  • your argument string($1) should be like this

user_id:pass@proxy.server.addr:proxy_port

  • If you do not use userid and password then argument string($1) should be

proxy.server.addr:proxy_port

  • you can export https_proxy and socks_proxy if you need.
  • To see if your proxy is set or not use env | grep proxy

To change system proxy using shell script try these:

gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.http enabled true
gsettings set org.gnome.system.proxy.http host 'proxy.server.addr'
gsettings set org.gnome.system.proxy.http port proxy_port

If you have user authentication pass and id

gsettings set org.gnome.system.proxy.http authentication-user 'user_id'
gsettings set org.gnome.system.proxy.http authentication-password 'password'

To use http_proxy for all other proxy

gsettings set org.gnome.system.proxy use-same-proxy true

To set bypass proxy for any host

gsettings set org.gnome.system.proxy ignore-hosts "['localhost',  '127.0.0.1', 'all', 'other', 'hosts']"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.