[ale] How to pass vars to lots of shell scripts?
leam hall
leamhall at gmail.com
Fri Oct 18 13:03:58 EDT 2013
So far, that's what I'm thinking. The process would be:
master script zeros out the param file
master script takes options given to it and writes to a param file
For example:
params.sh
TEST=0 # Test for condition, default true
FAIL=1 # Has not failed yet
FIX=1 # Default to do not fix
Called script looks something like:
. params.sh
THIS_VAR=0
<run something that sets THIS_VAR to not 0 if the test fails>
if [ THIS_VAR -ne 0 ]
then
FAIL=0
fi
if [ $TEST -eq 0 ]
then
if [ $FAIL -ne 0 ]
then
echo "This test passed"
else
echo "This test failed."
fi
fi
# TEST and FIX are separate; some runs might just test, some will fix.
if [ $FAIL -eq 0 ] && [ $FIX -eq 0 ]
then
echo "Time to fix this bad boy..."
<do fix stuff>
fi
On Fri, Oct 18, 2013 at 12:42 PM, chip <chip.gwyn at gmail.com> wrote:
> Could this be done by setting an environment variable then test for the
> value in your script and branch to do whatever.
>
> --chip
>
>
> On Fri, Oct 18, 2013 at 12:01 PM, leam hall <leamhall at gmail.com> wrote:
>
>> Hey all,
>>
>> I have a master script that calls a couple hundred other scripts. Each of
>> the "other" scripts can also be called in their own.
>>
>> What I'm thinking about is having a variable like "test" or "fix" be set,
>> so that if the "other" scripts run they will get a parameter without me
>> having to put a getopts stanza in each script.
>>
>> So maybe:
>>
>> . ./my_vars
>> if [ $TEST ]
>> then
>> ...
>>
>> or
>>
>> if [ -f ./TEST ]
>> then
>> ...
>>
>> Thoughts on the best way to do this? I'm not saying my ideas are the only
>> way, just what comes to mind.
>>
>> Leam
>>
>>
>> --
>> Mind on a Mission <http://leamhall.blogspot.com/>
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>>
>
>
> --
> Just my $.02, your mileage may vary, batteries not included, etc....
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>
--
Mind on a Mission <http://leamhall.blogspot.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20131018/15fbfb4e/attachment.html>
More information about the Ale
mailing list