ray4
December 3, 2023, 3:22am
1
I used the following code to run in sketchup ruby console:
require "open3"
command = 'echo Hello'
stdout, stderr, status = Open3.capture3(command)
puts "status: #{status}"
puts "stderr: #{stderr}"
puts "stdout: #{stdout}"
I expect that stdout will be Hello but there is nothing.
I also run the same code by Ruby standard and the stdout is Hello. How can I get sdtout in sketchup ruby console?
You likely cannot. STDOUT and STDERR have been “shoehorned” into the singleton Sketchup::Console object.
Console operations do not work the same in an embedded Ruby environment as they do in a standalone Ruby process.
This has been talked about here in the past. Search this category on “Open3” etc.
What is it that you really want to do ?
I get these results from Make 2015 & 2017:
ray4
December 3, 2023, 1:24pm
4
Thanks for your reply!
I wanna get some information which in stdout. But now, I already have another way to get stdout.
Just use Command line to write stdout into .txt file. Then use ruby sketchup to read that .txt
It does not seem to work in 2021, 2022 or 2023 (on Windows).