How to reset system proxy using pyhton code

Sum J sjsumitj at gmail.com
Mon Feb 19 03:57:23 EST 2018


Hi,

I am using below python code (Python 2.7) to reset the proxy of my Ubuntu
(Cent OS 6) system, but I am unable to reset the proxy:

Code :
import os
         print "Unsetting http..."
         os.system("unset http_proxy")
         os.system("echo $http_proxy")
         print "http is reset"

Output :
        Unsetting http...
        http://web-proxy.xxxx.xxxxxxx.net:8080
        http is reset
Process finished with exit code 0

It should not return ' http://web-proxy.xxxx.xxxxxxx.net:8080 ' in output.

I run the same unset command  from terminal , then I see that proxy is
reset:

[trex at sumlnxvm ~]$ unset $HTTP_PROXY
[trex at sumlnxvm ~]$ echo $HTTP_PROXY

[trex at sumlnxvm ~]$


Please suggest how to reset system proxy using Python Code

Regards,
Sumit



More information about the Python-list mailing list