Hello,
Many thanks all for the help
Here is Dan revisited code and checks. Need some improvements like checking Windows and Ruby version.
@DanRathbun
String.encode needed? Why?
How do you colorize your code on the forum?
so code picture
and code (thanks to Dan. I’ve got colorized code!)
def system_read(str_cmd)
begin
filename = nil
raise('system_read(str_cmd). str_cmd must be a string.') unless str_cmd.is_a?(String)
raise('system_read(str_cmd). str_cmd must not be empty string.') if str_cmd.length == 0
str_data = IO::popen(str_cmd) {|io| io.read}.strip()
bol_exit = ($?.exitstatus == 0)
if str_data.empty? or !bol_exit
filename = ENV['TMP'].encode('UTF-8').gsub('\\','/') + "/" + (Time.new.to_f * 1000).to_i.to_s
bol_exit = system(str_cmd + " > " + filename)
str_data = File.read(filename).strip()
end
return bol_exit, str_data
rescue => e
puts e.message
ensure
if filename && File::exist?(filename)
File::delete(filename) rescue nil
end
end
end
bol_exit, str_data = system_read('echo "Hello world!"')
puts " with Sketchup " + Sketchup.version.split(".")[0]+"\n "+
bol_exit.to_s + ", ->" + str_data + "<-\n end with"
now checks
PCintelWin7updatedWin10
with Sketchup 17
true, ->"Hello world!"<-
end with
with Sketchup 16
true, ->"Hello world!"<-
end with
with Sketchup 15
true, ->"Hello world!"<-
end with
with Sketchup 14
true, ->"Hello world!"<-
end with
with Sketchup 13
true, ->"Hello world!"<-
end with
with Sketchup 8
true, ->"Hello world!"<-
end with
PCamdWin10
with Sketchup 17
true, ->"Hello world!"<-
end with
with Sketchup 8
true, ->"Hello world!"<-
end with
PCintelWin7
with Sketchup 16
true, ->"Hello world!"<-
end with
with Sketchup 8
true, ->"Hello world!"<-
end with
all right. good news!
@john_drivenupthewall
may you run the script on your Macs and tell me results please?
@MSP_Greg or any other Windows User facing same issue
may you run the script and tell me results please?
Have a good day
WhyDi