![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing variables between scripts... | Jazmania | UNIX for Dummies Questions & Answers | 1 | 09-19-2007 06:48 AM |
| Passing variables to sed | jfisch | Shell Programming and Scripting | 3 | 03-07-2005 07:25 AM |
| Passing awk Variables | gozer13 | Shell Programming and Scripting | 3 | 01-04-2005 04:32 PM |
| passing variables | sounder123 | Shell Programming and Scripting | 1 | 06-10-2004 10:19 AM |
| Passing Variables to AWK | AreaMan | Shell Programming and Scripting | 5 | 01-28-2002 06:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Passing variables between scripts
Hi all.
I need to pass a value from a script that runs in a sub-shell, back into the calling shell like below (or into script 2 directly): outer_script export param=value1end outer_script I can't get this to work using regular variables and I have read some about shells and sub-shells and variables and I now believe that it's not possible with variables. I guess I could always use a file to store the value in script1 and then read it in script2 using the file. But if I go this way I'd be forced to have separate files for each user that executes the script so that no conflicts occurr. But then I'd get a lot of files that mess up. I guess I could then remove each file after the script completes but what if the user terminates using Ctrl+C? I'd still have a lot of messy files after a while. At the moment I'm leaning towards using files, but I thought I'd ask if someone knows another/better way to do this without using files? This is in Korn Shell |
|
||||
|
In your script1, you have to return the value, beacause the export is lost at the end of script.
At the end of 'script1', do 'exit $param' And try this : Code:
outer_script export param=value1 param=$(script1 $param) (in script1: export param=value2) script2 $param ($param is now value1, not value2 like i'd prefer) end outer_script |
|
||||
|
Quote:
![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|