Wednesday, March 5, 2008

Setting proxy for shell environment through script

I was fed up of writing long commands for setting http_proxy.So thought putting it as a script and invoking it whenever needed.

This was the one and only line in the script
export http_proxy=http://[ip address]:[port no]

I tried to invoke the script as normal
sh proxy.sh

The scripts works fine but the proxy settings does'nt change.
After lot of googling I found that it will work if we invoke in some other way.

. proxy.sh
([space] [dot] proxy.sh)

It worked...
I don't know what does dot stands for.I don't know anything of shell scripting...But planning to learn it....Hope to reply this post later..



1 comment:

  1. Hellloooo..
    this is because unix spawns sub shells when it sees scripts....

    But u can prevent it from starting a sub shell using "." the DOT command.which will run in the same shell....

    following link may be useful

    http://www.kingcomputerservices.com/unix_101/understanding_unix_shells_and_environment_variables.htm

    ReplyDelete