Hi!
Since I found no way to use aws-sdk gems within a SketchUp -extention I tried to find a workaround.
My task:
From the model-data I need to generate .json files and sync/upload them to an aws s3 bucket.
Since there is a problem in using the aws-sdk-s3 gems and uploading the files by ruby-code I tried a workaround: generate the files as .json-files and upload the files with aws cli.
On Windows I create a temp-file, store a generated aws cli command within the textfile, save it as .*vbs script and run the script:
my working code on windows:
file = Tempfile.new(%w[cmd .vbs])
file.write("Set WshShell = CreateObject(\"WScript.Shell\")\n")
file.write("WshShell.Run \"#{cmd.gsub('"', '""')}\", 0\n")
file.close
fileuri = URI.encode("file://#{file.path}")
UI.openURL(fileuri)
On MacOS I tried a similar approach but this only works just to a limited extent on the Mac.
I tried several things and ended up like this:
file = Tempfile.new(%w[cmd .sh])
file.write("#!/bin/bash\n")
file.write(cmd + "\n")
file.close
unless system "chmod", "755", file.path
UI.messagebox($?.to_s)
end
unless system "/bin/bash", "-c", file.path
UI.messagebox($?.to_s)
end
This approach is working fine ‘within the debug mode’ of SketchUp:
open terminal on MacOS and run:
/Applications/SketchUp\ 2024/SketchUp.app/Contents/MacOS/SketchUp -rdebug “ide port=17001”
I receive debug output within the terminal window. My bash script is called and is working (result of system command is ‘0’). .json files are being uploaded to aws s3.
But as a ‘normal run’ - when I just click in the SketchUp Icon and run SketchUp the system command of ‘system “/bin/bash”, file.path’ results in error ‘127’.
UI.messagebox($?.to_s)
pid ##### exit 127
Since “chmod” is working I would guess that there is no problem regarding user rights on the file system…
I would be very happy to receive any tips.
Thanks,
Dirk