In Cocoa, I am trying to implement a button, which when the user clicks on will capture the System profiler report and paste it on the Desktop.
Code
NSTask *taskDebug;
NSPipe *pipeDebug;
taskDebug = [[NSTask alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(taskFinished:) name:NSTaskDidTerminateNotification object:taskDebug];
[profilerButton setTitle:@"Please Wait"];
[profilerButton setEnabled:NO];
[taskDebug setLaunchPath: @"/usr/sbin/system_profiler"];
NSArray *args = [NSArray arrayWithObjects:@"-xml",@"-detailLevel",@"full",@">", @"
~/Desktop/Profiler.spx",nil];
[taskDebug setArguments:args];
[taskDebug launch];
But this does not save the file to the Desktop. Having NSArray *args = [NSArray arrayWithObjects:@"-xml",@"-detailLevel",@"full",nil] works and it drops the whole sys profiler output in the Console Window.
Any tips on why this does not work or how to better implement this ? I am trying to refrain from using a shell script or APpleScript to get the system profiler. If nothing work's that would be my final option. Thanks in advance.