below ism y code
if [ ip add show tun0 2>/dev/null ] ; then
export http_proxy="http://127.0.0.1:2123"
fi
But when i do echo after conencting
echo $http_proxy
it is not displaying. can advice?
CodePudding user response:
@GordonDavisson suggested:
if ip add show tun0 2>/dev/null
then
export http_proxy='http://127.0.0.1:2123'
fi
but you could also write it like this:
ip add show tun0 2>/dev/null && export http_proxy='http://127.0.0.1:2123'
ip
will print stuff on stdout when successful, so maybe you want to do >& /dev/null
? Instead of throwing all the data away, consider storing it in a variable, then you can always add a verbose flag to your program at some later point to print the content of that variable if you need to debug it.