Source or Execute an external Script from shell script
Hi All,
I know this is a simple to answer one... but its hard to search google for source'ing or executing a script with '. script'. Basically, i've realised it seems possible to have one script... test.sh Code:
#!/bin/bash Code:
#!/bin/bash Code:
./test.sh 123 456 Just wondering why this happens more than anything? Its not a problem or anything really... just interested. Thanks and Regards, M |
When you source a script, rather than call it explicitly, it inherits the environment of the script which sourced it. Therefore, the parameters passed to the original script initially, are available to the sourced code. When you source a second script into a first one, it acts as though the sourced code is part of the original script, i.e. it acts as though it were all one script.
|
Ahh course, should have known that really :-)
Thanks and great explaination! |
All times are GMT -5. The time now is 10:35 PM. |