swift - NSTask with defaults and killall bash commands -
I am trying to run the following two bash commands in the coco app:
default
Using NSTask, I have the following SWIFT code to execute the command when clicking on the button:
command = ["-a Let's write "kill, findall", "-c", "killall finder"] task = NSTask () task.launchPath = "/ bin / bash" task.arguments = commands = task.launch, "error, com.apple.finder CreateDesktop false", "-c", "killall finder" ()
I did not get any error while running the code but nothing really Does not happen when the button is clicked on any suggestions?
Are you sure nothing is this? You can not run many -c
arguments for this way, but when I try I execute my first order.
echo foo '-c' echo bar 'afu
In this particular case, the workaround is simple;
$ bash -c 'echo foo; Echo Bar 'FU Bar' / 'Code' More generally, the individual commands you were passing in the Bash did not need a shell anymore. To kill the finder simply,
task.launchPath = "/ usr / bin / killall" task.arguments = ["explorers"]
but Given this, you have a lot of commands, it really makes sense to walk from one shell.
function = NSTask () task.launchPath = "/ bin / bash" task.arguments = ["-c", "write default com.apple.finder CreateDesktop incorrect; killall finder"] Task.launch ()
Comments
Post a Comment