Ruby - writing output to a new terminal window
I was wondering if a ruby โโscript could open a new terminal window and redirect its output to that newly opened terminal window.
To open a new terminal I am currently executing system("gnome-terminal")
, however, after researching for a while, I still don't know how I could achieve the following ("pseudo code"):
variable = "test"
newTerminal = system("gnome-terminal")
puts variable to newTerminal
Is it possible even without major problems?
source to share
To do something like this on OSX (in case anyone is facing the same situation, yes, I know this does not answer this particular situation) you can do:
variable = "test"
`osascript -e 'tell app "Terminal"
do script "echo #{variable}"
end tell'`
Note. This is not exactly the same as using puts
, as it would actually echo multiple times if you wanted to print multiple things, but this is more of a basis for solving a similar problem.
source to share