How can we return value from ruby script?
#!/usr/bin/env ruby
a = "test"
a
How can we access the value of 'a' in Ubuntu terminal or java or c?
print your variable within ruby/python script, it can then be read from a shell script by example :
#!/bin/bash
ruby_var=$(ruby myrubyscript.rb)
python_var=$(python mypythonscript.py)
echo "$ruby_var"
echo "$python_var"
take care your ruby/python script only print this variable ( there are more complicated ways with named pipes by example for more interaction ).
If the value is an integer between 0 and 255, you can use the exit status
$ ruby -e 'var=42; exit var'
$ val=$?
$ echo $val
42
set -e in your terminal, then try that example in your answer again. My point is, while you technically can use the exit status to return values from Unix commands, I wouldn't recommend using it in a real application for anything other than error codes.
$stdout. This will output to the standard output stream. You could also right the results to a file and parse the file after the script completes. Here is a nice little post on the subject of IO in Ruby