I am new to ruby. Still learning it.
I have bash script and a ruby script, having independent responsibilities.
The bash script calls the ruby script with some command line arguments. The ruby script, after parsing these command line args will set/unset some variables local to it. These variables will have the same use/name in the parent bash script.
So, i need to have the modified values of the variables in the ruby script be reflected in the parent bash script also.
Couple of approaches I have thought of are:
1.) Export the variables to the environment in bash, then have ruby modify them by using the ENV[]
hash. In this case, there wouldn't be any need to have local variables in ruby to store these values, ruby would directly modify the imported variables from bash, as they are environment variables. However, would these changed values of the environment be reflected in the bash script?
2.) After the ruby script returns to the parent bash script, call on some methods of ruby that will return the a variable's value to it. So for each variable, a method is called. Something like for python,
python -c 'import python_module; print python_method()'
Is this possible in ruby?
If none of the above two are possible, is there any other way to have the values of ruby variables be reflected back in the parent bash script?
Or, is there any scripting option other than ruby/python that can help me do this?
I Appreciate the time in reading this post and helping me out. :-)