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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With