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@xxxxxxxxxxxxxxxx http://www.jorgensen.org.uk/
karl@xxxxxxxxxxxxx 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



Relevant Pages

  • Re: Modelling Complex Sentences
    ... re-inventing the network data model). ... If such as classifying node does not exist, ... Since people complained that dbd's scripts were too long, ... you typically use the CREATE/INSERT commands to ...
    (comp.databases.theory)
  • Re: Change IP related values due to WAN design change
    ... Unknown network, ... For the cost of testing a dangerous script in a big ... > recurse your text file into an array. ... > var newSettings = new NetworkSettings; ...
    (microsoft.public.windows.server.scripting)
  • Re: Request help with simple network
    ... You do need to let DNS queries through the firewall, ... >> well as web browser connections. ... the machines behind the network to get them working (they just had the ... Below is my networking script, I run it *ONCE* on my gateway PC, whenever ...
    (alt.os.linux.redhat)
  • CW committed to schedule of scripted dramas
    ... The CW is sticking with the script. ... That?s the word from CBS Corp.?s Nancy Tellem and Warner Bros.? ... to building a network based on original hourlong dramas. ...
    (rec.arts.tv)
  • RE: Logon Script Issues
    ... The network still has the same subnets. ... Yes we have a new dns server. ... The script does have mappings and uses AD groups to do mapping. ... We have tried a Kixtart script and a VBS script with the same results. ...
    (microsoft.public.windows.server.scripting)