<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>If I understand what you're asking, this is what the export keyword is for.<div><br></div><div>----------x.sh-------------</div><div>X=test</div><div>y.sh</div><div>export X</div><div>y.sh</div><div>-----------y.sh----------</div><div>echo X=$X</div><div>------------------------</div><div>$ ./x.sh</div><div>X=</div><div>X=test<br><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"leam hall" <leamhall@gmail.com><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org><br><b>Sent: </b>Friday, October 18, 2013 1:03:58 PM<br><b>Subject: </b>Re: [ale] How to pass vars to lots of shell scripts?<br><br><div dir="ltr"><div><div><div><div><div>So far, that's what I'm thinking. The process would be:<br><br></div>master script zeros out the param file<br></div>master script takes options given to it and writes to a param file<br>
</div>For example:<br><br>params.sh<br> TEST=0 # Test for condition, default true<br> FAIL=1 # Has not failed yet<br> FIX=1 # Default to do not fix<br><br></div>Called script looks something like:<br><br>. params.sh<br>
<br>THIS_VAR=0<br><br></div><run something that sets THIS_VAR to not 0 if the test fails><br><br><div>if [ THIS_VAR -ne 0 ]<br>then <br> FAIL=0<br></div><div>fi<br><br>if [ $TEST -eq 0 ] <br>then<br></div><div>
if [ $FAIL -ne 0 ]<br></div><div> then<br></div><div> echo "This test passed"<br></div><div> else<br></div><div> echo "This test failed."<br></div><div> fi<br></div><div>fi<br>
<br></div><div># TEST and FIX are separate; some runs might just test, some will fix.<br><br></div><div>if [ $FAIL -eq 0 ] && [ $FIX -eq 0 ]<br>then<br> echo "Time to fix this bad boy..."<br> <do fix stuff><br>
fi<br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 18, 2013 at 12:42 PM, chip <span dir="ltr"><<a href="mailto:chip.gwyn@gmail.com" target="_blank">chip.gwyn@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Could this be done by setting an environment variable then test for the value in your script and branch to do whatever.<div>
<br></div><div>--chip</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">
On Fri, Oct 18, 2013 at 12:01 PM, leam hall <span dir="ltr"><<a href="mailto:leamhall@gmail.com" target="_blank">leamhall@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hey all,<br><br></div>I have a master script that calls a couple hundred other scripts. Each of the "other" scripts can also be called in their own. <br>
<br></div>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. <br>
<br></div>So maybe:<br><br></div>. ./my_vars<br></div><div>if [ $TEST ]<br></div><div>then<br>...<br></div><div><br></div>or <br><br></div>if [ -f ./TEST ]<br></div>then<br></div>...<br></div><br></div>Thoughts on the best way to do this? I'm not saying my ideas are the only way, just what comes to mind.<span><font color="#888888"><br>
<br>Leam<br><br clear="all"><div><div><div><div><div><div><div><div><div><div><div>
<br>-- <br><div><a href="http://leamhall.blogspot.com/" target="_blank">Mind on a Mission</a></div>
</div></div></div></div></div></div></div></div></div></div></div></font></span></div>
<br></div></div>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Just my $.02, your mileage may vary, batteries not included, etc....
</font></span></div>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div><a href="http://leamhall.blogspot.com/" target="_blank">Mind on a Mission</a></div>
</div>
<br>_______________________________________________<br>Ale mailing list<br>Ale@ale.org<br>http://mail.ale.org/mailman/listinfo/ale<br>See JOBS, ANNOUNCE and SCHOOLS lists at<br>http://mail.ale.org/mailman/listinfo<br></div><br></div></div></body></html>