UI.openURL(executable + params)
-
Use the "system" call or backticks for this purpose, i.e.:
s = system "dir" # -> true s = `dir` # -> a lot of stuff ;)
Don't use "exec"!
Executables on Mac do not have a special extension, because file extensions are not relevant for the OS in most cases. Executables are marked as executable in the file system. You can make Ruby scripts executable, i.e. by calling "chmod +x" AND writing down a Shebang line on top of the .rb file.
azuby
-
I don't agree with Rick, openurl is not restricted to internet links.
One can write: UI.openURL("file://" + the_file_to_open)
The system then uses the registry to launch the correct app.
You can also write UI.openURL("c:\test.exe"), this will launch the programm "test"
I guess you could do it also on Mac, but there are no registry and extensions on it...
I don't know if you can add parameters to the command
Regards, -
Thanks Lads,
Azuby has killed me, I hope I will recover soon .
I need to run Kerkythea.exe (on Mac kerkythea) with single parameter (KT script file name).
On PC I create separate start.bat file containing :
kerkyhea.exe start.kstThen I run this batch using UI.openURL(C:\start.bat) which opens command line window, starts batch file and finally opens KT. 'Dos' window is visible in the background so it is not clean solution.
Azuby - how it will look using your backtick?
Tomasz
-
@didier bur said:
I don't agree with Rick, openurl is not restricted to internet links.
One can write: UI.openURL("file://" + the_file_to_open)
The system then uses the registry to launch the correct app.
You can also write UI.openURL("c:\test.exe"), this will launch the programm "test"
I guess you could do it also on Mac, but there are no registry and extensions on it...
I don't know if you can add parameters to the command
Regards,I didn't say you couldn't open an app, I said you couldn't use parameters.
Just because something can be done doesn't mean it was intended. So, because the method accepts an URL (even a local one), and because URLs don't have parameters, then it won't work for what is being attempted (even though opening an app without using parameters will work). -
@unknownuser said:
Azuby - how it will look using your backtick?
Germans are not funny , so I don't know, whether this is just fun question. Backticks are one of these little diacritic marks i.e. French use on "a", "e" and so on: "à", "è" ... Look my code above, I wrote
**dir**
. Between the backticks you write the call as you would write it in batch file or command line; for a coloured directory listing on Mac you could writels -Glas
orls -G -l -a -s
. If you do not need the result of the call, just information whether it failed or not, use the "system" call, if you want to get the result, than use backticks. And if you want to kill Sketchup, use "exec"azuby
-
@unknownuser said:
'Dos' window is visible in the background so it is not clean solution.
I think if you use the command "start" before the name of the executable, the dos window will disappear after executing the batch file.
start kerkythea.exe script.kst
Whaat
-
Thanks Azuby,
Don't worry. I am not familiar with MACs at all. You are simply at the much higher level of programming then me, so most of what you are writing sounds like a Chinese to me I simply would like to start Kerkythea on MAC with start.kst file as a parameter (file to be opened when KT starts).
By the way, next version of KT is expected in few months and it will be available for MAC!
It is what Giannis says.Thanks Whaat,
I have done some investigation and the line in the batch file should look like:
start "" "C:\Program Files\Kerkythea\Kerkythea.exe" "start.kst"
Now it works (PC only )!Tomasz
-
Azuby, I have finally understood what you have written in you first post (I am not very familiar with standard Ruby methods). It works excellent with "dir", but for some reason KT is being opened only when I close SU otherwise SU is hanging and KT awaiting to start (edit - it takes about 40sec KT to start).
system("Kerkythea.exe start.kst")
s=`Kerkythea.exe start.kst`
works fine. Is it possible to run KT as a separate thread,
so SU would be still working?Tomasz
-
s=`c;/Program Files/Kerkythea/Kerkythea.exe "c;\\Program Files\\Kerkythea\\start.kst"`
It is script that will run exe with parameter in "" (PC).
For MAC I presume I will have to replace all \ by /.Still don't know how to keep SU alive when KT is running.
Tomasz
-
Moin,
you can't do this with Ruby threads, they let Sketchup freeze while your other application is running. The code would be
Thread.new do `WHATEVER` end
Also you can't use exec or fork. The only way would be writing a really simple server application, running it on localhost and call it from Sketchup.
azuby
-
Any ideas what's causing this glitch ?
help=Sketchup.find_support_file("RoofHelp.mht","Plugins/")
#=big file, but works...help=Sketchup.find_support_file("RoofHelp.pdf","Plugins/")
#=small file, but not working ???UI.messagebox("ERROR\nRoof Help File NOT found.") if not UI.openURL("file:///"+help)
On a PC with Vista UI.openURL will open almost any type of file except a PDF ?
This is delaying my beta issue of Roof.rb as it needs a help file !
-
The file name is case sensitive. Does it matter?
Try dir with the folder and look for the file.upcase.
Tomasz -
I don't think it's the case or another thought I had was even blank-spaces in paths (tried gsub 20% etc without any change in results).
It just seems to dislike PDF files - other types - mht, htm, doc, txt et al work OK...
Is it a setting in Vista ?
-
I have no idea. I am working on XP.
-
@unknownuser said:
I have no idea. I am working on XP.
Thanks anyway.
Just upgraded to a new PC - Core 2 Quad with 2Gb RAM - but it runs Vista...
Vista seems to be the problem...
Advertisement