It is currently Mon, 27 Jun 2022 12:28:54 GMT



 
Author Message
 export variables to calling shell in a shell-script

Hi!

the (bash) shell-script

-----
#!/bin/sh
export blubber=blabber

-----

should set the variable blubber to the value blabber in the shell, from
where I call the script...but it DOESN'T...any suggestions?

Thanks in advance,

Holger Hartmann

Sent via Deja.com
http://www.**-**.com/



 Thu, 24 Jul 2003 01:16:02 GMT   
 export variables to calling shell in a shell-script
On Sat, 03 Feb 2001 17:16:02 GMT, Holger Hartmann

Yes, invoke it differently.  Do either
source scriptname
        or
. scriptname

Either one will run the script in the current shell, and not a sub-shell.

Mark Post

Postmodern Consulting
Information Technology and Systems Management Consulting
To send me email, replace 'nospam' with 'home'.



 Thu, 24 Jul 2003 03:13:22 GMT   
 export variables to calling shell in a shell-script

No it should not.
It should set the variable blubber in the shell it is running.
Running a script starts a new shell in which the script is executed.
If the script finishes, the shell it ran in is killed.

If you want it to run in your current shell, you'll need to source it.

Eric



 Thu, 24 Jul 2003 16:51:50 GMT   
 export variables to calling shell in a shell-script

Firstly, no, it shouldn't (and can't) set anything in a separate calling
process.

Either you want to source the script to be read by the current shell,
or you want to have the script return a value which can be assigned to a
variable by the calling process if it wishes to.

--
        Craig Macbride <cra...@earthling.net>
-----------------------http://www.nyx.net/~cmacbrid------------------------
        "It's a sense of humour like mine, Carla, that makes me proud
                to be ashamed of myself." - Captain Kremmen



 Thu, 24 Jul 2003 20:12:03 GMT   
 
   [ 4 post ] 

Similar Threads

1. export variables to calling shell in a shell-script

2. Exporting Enviroment Variables in shell scripts

3. Shell Variables: Shell prompt OK, script, NO.

4. file contents into variable, or global variable from shell script

5. Passing a variable from a Perl script to a shell script

6. Passing a variable between shell script and perl script

7. make - exporting shell variable to environment

8. exporting C shell variable

9. how do I export a shell variable

10. Adding/Changing an exported Shell Variable


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software