Well, I don't use shell scripts for anything outside of a collect of shell commands. But, to start, using curl, to set the proxy, is not a good idea; it is better, to proxy through the routing, layer 2 if memory serves me right. Look at ifconfig, ip, iptables, and ebtables (all commands). Curl is okay to use for web applications, but outside of that, you would be better off using distinct protocols, such as telnet, ssh, mysql, ect..
Second, I don't recall "do" being used with "for" loops; that is for "do-while" loops. Also your curl command has it directing the output to "/dev/null" aka the blackhole. So even if it did work, you wouldn't know.
I would suggest to learn C/C++/Obj-C; also
http://ss64.com/bash/ great place to catch a quick reference to commands, also the "man" command is always useful, same with " --help".