File.startAsProcess
-
Hello to all,
how do I use File.startAsProcess()? If I give an empty string as a parameter (“”) the file is simply copied and the folder containing the file is opened. But I want it to be executed.
@d-healey I think you had implemented the function. Do you have a tip here?
This is my code:
inline function installPlugIns() { local installerApp = downloadsFolder.getChildFile(fileNames[0]); installerApp.startAsProcess(""); }
Thank you very much
Oli -
@Oli-Ullmann Does the file have execute permissions?
-
@d-healey
I have added this to my script:installerApp.setExecutePermission(true);
Still the same behavior...
-
@Oli-Ullmann What happens when you run the file from the commandline manually (outside of HISE)
-
@d-healey
When I use "open QUADRIUM_0_9_Beta_r0002.pkg" in the terminal it opens the application.When I use "open -a" it says it is unable to find application. Maybe because it is a pkg file?
-
@Oli-Ullmann You have you to use
open
? -
@d-healey
If I just type "QUADRIUM_0_9_Beta_r0002.pkg" it says "command not found".
Maybe because it is a pkg file?
And if so is there a way to start/open pkg files from within HISE? -
@Oli-Ullmann Seems strange, are you using a bash terminal?
-
@d-healey
I work on the Mac and use the build in terminal. -
@Oli-Ullmann But is it using bash or a different shell?
-
Oh I have an idea, let me test something
-
@d-healey
It says "zsh: command not found" so I guess it's not bash. But to be honest, I'm not really familiar with it. -
@Oli-Ullmann Yeah I checked, on MacOS now it defaults to zsh instead of bash, but actually it seems the issue is that you must use the open command.
You might know this already but I'll give a little explainer just in case you don't. When you run a "command" from the terminal on any OS, most of the time that command is not actually a command but it's running a program. For example when you run
cp
to copy a file, you are actually running a program called cp.In the present situation you are running a program called
open
and passing the file you want to run as a parameter.So my idea is instead of trying to execute the pkg file, you instead execute
open
and pass the pkg as the parameter in the parenthesis.To do this you'll need to get the
open
program into a file object. Usually these stock programs are in /usr/bin, but you can usewhich open
to find the location if you need to.Putting it together:
inline function installPlugIns() { local openCommand = FileSystem.fromAbsolutePath("/usr/bin/open"); openCommand.startAsProcess(fileNames[0]); }
Let me know if it works.
-
@d-healey
Unfortunately, that doesn't work yet either. I have checked with “which open” where the open program is located and it is also located at the path you specified.I have also tried this variant, but it still does not work.
inline function installPlugIns() { local installerApp = downloadsFolder.getChildFile(fileNames[0]); local openCommand = FileSystem.fromAbsolutePath("/usr/bin/open"); openCommand.startAsProcess(installerApp.toString(0)); }
I also used if(openCommand.isFile()) to check whether the file really exists.
-
@Oli-Ullmann Ok, I'll fire up my Mac VM and see if I can figure it out
-
@d-healey
Thank you very much David! As always, you are a great help! -
Works here, make sure your installerApp path is correct
HiseSnippet 904.3ocsUE0aaaCDlxIJXVcaXEnOsmD7SJEEV1wI1AnXXI1IdyXyoFyoEaOUPQQEyFJRARprYLz+y6eP6QIkH4lfzVCL+fgNd2GuO9w6NtPIITsVpPNdWtNihb9V2kqElUSVgYBzryPN64ZnZCZ75LrVSiQNN67KVeNs2EU76+94wXNVPn0KgPuQxHzemkxL0qt3jeiw4SwwzKYoMh9vSlQjhIRtLG3wNt8PYXx03qnWfsg0xE8qX8JjyycSFN3viNlb.cvnAGPGEM53iiHC5czv3XJ9P7n9wjgQzQ.I267XlQpVZv.6gMcrLd8xUx+VTlf2vzrHN0ZzGsDxb4xnIqX73E2JJZDxY2E0RzNkRzybmyhY2sdsT8CEN7qQzTzbZ8XTp+WAkbZPocKozScWRTrLSsGKedh6LggpRvvcSSpTFKp0O1xchDhPX5lhulNUAF2gHXXuduvG9a+W54A2OZiuj3+S9SYb5x0ZCMsahRldZjVxyMzEXypfNg4ZUXDSDJynhNVjdLAmIn9I4BhgIE9Rw3biQJ5aSsRxCHxzLo.HwK7uAyyo668udsYI9AUVsaqnlbk3kvWds4RBl6y.5f4bpxlVfTcBeslpzguStRDdFUesQlEBhw6nDiNboTEyD3w4fRFdGzvnB6Jmcyt9pNPJ7ZKIcgHTlS0UpYvFYCNTuGNW2JbWQMSt8.Dzo5n0Y+tZ65EGvI.zHnfN3SO4vN0PUtPZnuRDTb58dum+m5JI4A8UsW.4dP21NM0iALPjmFQUM0dafPk0lkq68kUtRJkkFAJEyDLyqf5gR6oRdrsLz988KtQU5J70qmcF1fs06UqAwkQUFlkNNmQuAlvTV821s5JuH1pKCfxlBueeUuQo3iXwV.U2Dn+odLzecx5ZiKOQiugNSrPQgaRaSCSOWlB6KVAg4zBc+lPn8WFmywlMmIXmVV4.T9MZDsMaBMyrt4zzuhAE8dzAEeoT7otKXFxpGlisd.NB2I+evwpwqem64IIPeaMA20c5etsyR+Lo+Oj4Fl3p4XihA0BtWjmtDdFhPgrKDTNr4tvksEZgcOqsUAVREwEFe.9U4ru01oxY+achRwDk7sjx9M6.7uoXEfShhG3Z6N2Z62GUzC1TmSg2SdKgr4VcOfGrs.Grs.ObaAdz1Bb31Bbz1B73OOP6y8mlajoksMHz7EmWLzxw4bAFp.KpVQeDcyfp1B
-
I used the time to try this out in an empty project:
const dlfolder = FileSystem.getFolder(FileSystem.Downloads); const f = dlfolder.getChildFile("QUADRIUM_0_9_Beta_r0002.pkg"); if(f.isFile()) { f.startAsProcess(""); }
It works! So there must be another problem in my code.
const dlfolder = FileSystem.getFolder(FileSystem.Downloads); -
@d-healey
Yes, there must be a different problem!Nevertheless, thank you very much for your help David!
-
@d-healey
Stupid mistake! I was referring to the zip file in startAsProcess(“”) and not the pkg file.
So the installer was not copied as I thought, but it was unpacked again.Thank you very much, David. The correspondence with you helped me to find the error.