You are not logged in.

#1 2005-05-09 08:16:04

pengman
Member
Registered: 2005-02-23
Posts: 4

Help with Script

Hello all

I want to create a script that detects what network my laptop is on and sets a  few things, but I have run into a few problems:

1. what is the "right" way to run this? I can make it a executable file, but then I would have to manually run it each time... Could it be made a daemon? The scripts in /etc/rc.d/ seems simple enough for me to copy .. but is this "right"?

2. I need to export the variables http_proxy and ftp_proxy, how can I do that for a script? If I just use a export statement, the variables is only in the scope of the script itself...

I hope I can get some help with this...
/Pengman

Offline

#2 2005-05-09 09:17:18

leeghoofd
Member
From: the Netherlands
Registered: 2005-04-28
Posts: 61

Re: Help with Script

Hi pengman,

I think the right way to do this is make you script executable and place it in /usr/local/bin then make a daemon and let it stop/start you script

I don't know excacly what you mean with export, I thinkit just works, for instance try this:
script1:

export var=blabla
./script2

script2:

echo $var

The export command will set the variable for that login. So in that script and all other programs/script it calls the exported var will be readable. But if you login again (start for instance a new terminal) you have to export it again thats why a lot of exports are in the file ~/.bashrc so they are exported on every 'login'

Offline

#3 2005-05-09 10:12:18

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: Help with Script

the export will work/notwork depending on how your script is called. If it is called and spawns an external shell (most scripts do this) then the export will indeed not remain for any subsequent scripts.

If you need the values for something universal, consider adding it to a script that gets sourced on startup (/etc/profile), create an /etc/profile.d/foo file and add it there, or create a seperate file somewhere else and have each script needing that value source it. (. /script)

Hope that helps a bit..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

Board footer

Powered by FluxBB