bash programming question - hand over variables to another script
Hey guys!
I searched the internet over and over, but couldn't find a solution, basically because of not knowing exactly how I should entitle it :/. I try to describe. I have the following script (just a test case): Code:
#!/bin/bash wrapper.sh TEST=yes wrapper.sh: Code:
#!/bin/bash |
Your sample program doesn't match the question you posted.
It performs the command you pass as an argument to the script. Here is a similar example: Code:
cat indprog.sh Code:
cat >testprog.sh VAR1=$(./script) Is this what you had in mind? Code:
cat test2.sh |
If you change test.sh to
Code:
#!/bin/bash Code:
#!/bin/bash |
Thanks for the fast responses :).
Quote:
Quote:
Instead I get "TEST=yes: command not found" I would like to tell bash somehow, that $1 isn't a command, but a variable I want to pass on to test.sh tronayne: Almost. But fact is, I can't change test.sh (for my purpose). And I do really need to pass the variable before the actual script. |
Quote:
If you do the first, all child processes of wrapper.sh (and whatever any additional child processes are called from the children) will be able to use that variable; the variable will cease to exist on exit. If you do the second then any process in the stream (wrapper.sh, test.sh, etc., etc.) will be able to use or change the content of that variable and it will still available after everything exits; i.e., you'll be able to echo ${TEST} after everything runs and see the final value. |
Code:
#!/bin/bash |
All times are GMT -5. The time now is 07:19 PM. |