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: ntp woes (and more-general questions about startup and logging)
    ... the script didn't run the "stop" ... Our 10.4 machines are 10.4.7. ... been thinking that the underlying network, ... deny) what traffic (IP + port) goes to what port. ...
    (comp.sys.mac.system)
  • Re: split/isolate network
    ... R> as part of the network set-up? ... R> A script is how you would make it permanent. ... R> writing your own firewall rules. ... R> You'll also want to read up on NAT ...
    (Ubuntu)
  • 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: OT: the detection of illegal gateways
    ... I suggest checking if the script exists in the NMAP scripts, if the script isn't there then NMAP will have all the tools you need. ... plugged into the network (for creating a "faster" connection to the internet ... Sonar cleverly uses traceroute for detecting routers that illegally exchange ...
    (Pen-Test)
  • Re: Is this proof that systemd is completely broken?
    ... systemd will start the *.service first! ... a server with only statically configured network interfaces. ... documentation, systemd must wait until this script is complete, before ... Interface: lan0 is up ...
    (Fedora)