Running CHMOD

I’m trying to use ChildProcess to run CHMOD so I can give write-access to my DATA folder. Is this the only way to do it? So far if I create a SH file with what I need and call from ChildProcess it works. But I would like to have a more direct method of doing that if possible.

If I try to just pass all the parameters instead I get just the output of the parameters and no changes to the folder I’m trying to mess with. :wink:

Cheers, WilliamK

Hi WilliamK surprised to see you are still here, lol, I bought you’d be a retired rich man by now.

According to other users, it won’t be possible to use this mechanism on Catalina, because it now requires an admin password for file access, so the shell just hangs waiting for the user’s admin password. Are they wrong? If you have a workaround that would be very good news.

:-p Nah, still working hard. :wink:

Oh Apple, always making shit… no idea indeed. Will see if I find something. I did manage to call the .sh script but it does nothing.

I’m trying to use ChildProcess to run CHMOD so I can give write-access to my DATA folder.

Is this relevant?

Turns out it was the writeString that got my all wrong. As it adds some extra chars at the end which makes the SH no longer runs… I used writeText (the correct one) and now it works. Oh boy… I’m getting old… :wink: Thanks again guys. Will post the code once is all done.

1 Like

Here we go. :slight_smile:

				String thePassword;
				AskPassword("Sets the Wusik Engine Data folder as read/write.", thePassword);
				File runScript = File::addTrailingSeparator(File::getSpecialLocation(File::SpecialLocationType::commonDocumentsDirectory).getFullPathName()) + "";
				ScopedPointer<OutputStream> fstream = runScript.createOutputStream();
				fstream->writeText("echo '" + thePassword + "' | sudo -S chmod -R 777 '" + getEffect()->dataFiles->dataFilesLocation + "'", false, false, "");
				fstream = nullptr;
				StringArray xP2;
				ChildProcess xProc2;
				String xError = xProc2.readAllProcessOutput();
				StringArray xParams;
				ChildProcess runWPProcess;
				xError = runWPProcess.readAllProcessOutput();
1 Like