[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: exporting a variable to global shells



On Fri, May 11, 2007 at 03:24:46PM +0200, Jan-Florian Hilgenberg wrote:
> Hi guy's, first I am german, so ignore my bad english please ;-)

Kein problem. (or is it "Keine problem"? feminimum for "problem" is so 
much more appropriate than neutrum/maskulinum...)

> i want to get a variable out of a child shell in it parent shell, the sense
> is, that I want to use the ProxyServer of my school automaticly if it is
> pingable, the script isn't hard but the variable isn't fully global after
> exporting it

No. It wouldn't be. Environment variables are a user-space concept - 
messing with the environment variables for other processes means messing 
with their private memory. And that's not allowed.

> my script:
> #!/bin/bash
> ping -c 1 192.168.4.4 && export http_proxy="192.168.4.4:8080"
> echo $http_proxy #for debugging
> 
> When the script is exiting the echo stdout's the proxy adress, but if I am
> back in my parent shell, the http_proxy variable is empty.
> The script should be run by the command post-up in the
> /etc/network/interfaces.

For the "detect-where-you-are" bit you may want to have a look at using 
guessnet - I've had great success with using this for (automatically) 
setting up my network differently depending on where/what I connect to.  

In your case, it could recognize the MAC address of the proxy server or 
some other hosts known to be on the network.  Using the IP address is 
unreliable as other networks may have a host with the same IP address.

With regard to actually *setting* the proxy server, this varies.  I've 
resorted to having my post-up script in /etc/network/interfaces 
automatically reconfigure ntlmaps, and then just set my apps to use 
ntlmaps as a proxy.  When I'm home, I fire up bfilter on the same port 
(but this bit is not yet automated. Haven't had time)

The above works for me with regard to HTTP traffic. Since then I've 
implemented my https-based VPN to my main server which takes care of the 
rest.  So I can really ditch the http-proxy bit by now ...

> And because it was so fair, i explain you an other problem.
> I have disabled the "auto" option for eth0 (ethernet) and eth1(wlan) because
> i change the network (home, school, work, friends...) continously and if
> there is no dhcp server or no cable in the ethernet(network/interface) then
> it needs a long time to bootup.

yes: auto is only really useful for fixed interfaces with permanently 
plugged-in cables.

Do you run ifplugd? This is designed to bring up an interface as soon as 
a cable is plugged in (or a wireless AP is detected).

> But i wish that my System get a IP for ethernet on every bootup, I know
> there is the option to put a process in the background by "command &", where
> i have to change the option?

Do you really need an IP on *every* boot-up?   Even when not connected 
to anything?  If so, why?

Hope this helps

-- 
Karl E. Jorgensen
karl@jorgensen.org.uk  http://www.jorgensen.org.uk/
karl@jorgensen.com     http://karl.jorgensen.com
==== Today's fortune:
HERE LIES LESTER MOORE
SHOT 4 TIMES WITH A .44
NO LES
NO MOORE
		-- tombstone, in Tombstone, AZ

Attachment: signature.asc
Description: Digital signature


Reply to: