Jack Jack - 6 months ago 32
Swift Question

Run a .sh file from swift?

I really need to be able to have a .sh file ran from swift! I looked into t and for some reason people want me to run the shell program in the swift file but it doesn't end up working. I'm trying to run one command, really. The shell command does need argument which is going to be passed into from the app, though. The command I'm trying to run is:

chmod a-x /Applications/the input here

I also must be able to take the users input to put the password. How would I input the password?


I have already tried:

import Foundation
let task = NSTask();
task.launchPath = "/bin/chmod"
task.arguments = ["a-x /Applications/application.app"]


Does anyone have any tips?


Figured it out! I did not know that the arguments had to be like this:

task.arguments = ["a-x", "/Applications/application.app"]