![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing environment variables to parent shells | konndanley | UNIX for Dummies Questions & Answers | 3 | 08-04-2007 02:15 PM |
| parent shell pid | maheshwin | Shell Programming and Scripting | 4 | 01-30-2007 09:19 PM |
| How to pass CSH variables up to the parent? | ElCaito | Shell Programming and Scripting | 0 | 11-29-2006 11:30 PM |
| How to know parent script | raki | SUN Solaris | 1 | 06-06-2006 01:03 AM |
| can you change direcotry using variables? | jsalz638 | Shell Programming and Scripting | 4 | 07-06-2004 05:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to change parent shell's variables?
I have a question about how to change variables in parent shell.
My script, test.sh, is below: #!/bin/sh # test.sh PATH=. The commands I ran for test: $ echo $PATH .:/usr/bin:/usr/sbin:/usr/local/sbin: $ sh test.sh $ echo $PATH .:/usr/bin:/usr/sbin:/usr/local/sbin: Note that when I run sh test.sh, the variable PATH was not changed. I know that I can run . test.sh to make it change PATH. But for some reason I have to run sh test.sh. So in this case, how to make child process change the variables in parent process? Thanks. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
The parent shell can't inherit variables from the child but you can run your script in the current shell with (first make your script executable):
Code:
. scriptname Code:
source scriptname |
|||
| Google The UNIX and Linux Forums |