Re: Launch Path Not Accessible
Re: Launch Path Not Accessible
- Subject: Re: Launch Path Not Accessible
- From: "Omar Qazi" <email@hidden>
- Date: Sat, 2 Aug 2008 14:59:07 -0700
- Resent-date: Sat, 2 Aug 2008 20:13:49 -0700
- Resent-from: "Omar Qazi" <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
Steve:
You don't need to chmod the file NSTask is really meant for executing
Mach-I executables, so the launch path needs to be the interpreter.
For example, if this is a ruby script your launch path would be /usr/
bin/ruby and your first argument would be the first argument. If it's
a shell script you would use /bin/sh and the script would be the first
argument (and so on and so fourth).
Omar Qazi
Hello, Galaxy
1.310.294.1593
On Aug 2, 2008, at 2:19 PM, "Steve Cronin" <email@hidden> wrote:
> Andrew:
>
> Thanks for the slap on the head!
> So I chmod'ed the file and no longer get the 'not accessible error'
> YEAH!
>
> BUT now I get:
> *** NSTask: Task create for path '/Users/steve/Library/Application
> Support/XYZ/Scripts/myUseful.o' failed: 88, "Malformed Mach-o file"
>
> So I must be missing something about the contents of script files.
> Here's my script:
>
> myUseful.m
> #import <Cocoa/Cocoa.h>
> int main(int argc, char **argv)
> {
> char dummy;
> read(STDIN_FILENO, &dummy, 1);
> [NSAutoreleasePool new];
> NSURL *url = [NSURL fileURLWithPath:[NSString
> stringWithUTF8String:argv[1]]];
> LSOpenCFURLRef((CFURLRef)url, NULL);
> return 0;
> }
>
> You will just have to trust me that I DO need to launch the file in
> this manner.
> What do I need to do to this file to make it into the correct format?
>
> THANKS AGAIN for the chmod help!
> Steve
>
> On Aug 2, 2008, at 3:26 PM, Andrew Farmer wrote:
>
>> On 02 Aug 08, at 13:01, Steve Cronin wrote:
>>> I'm trying to do something that seems like it should be easy, but
>>> I'm stymied by what I think is a permissions error I don't
>>> understand.
>>>
>>> I'm trying to run a script using NSTask.
>>> I have the static script stored as a separate file in my bundle.
>>> I have created a folder in my "Applications Support" directory
>>> called "Scripts" and copied my script and several items into this
>>> directory.
>>> Note that this has a space in the full pathname!
>>>
>>> SO I have tried the following:
>>> NSString *myScriptPath = [[self scriptsFolderPath]
>>> stringByAppendingPathComponent:@"myUseful.script"]; //yes I have
>>> verified this is a valid path!!!
>>> NSTask *task = [[[NSTask alloc] init] autorelease];
>>> [task setLaunchPath: myScriptPath];
>>> [task setArguments:[NSArray arrayWithObject:...]];
>>> [task setStandardInput:[NSPipe pipe]];
>>> [task launch];
>>>
>>> ERRROR: launch path not accessible
>>
>> Are you sure myUseful.script is directly executable? Just because
>> it's double-clickable in the Finder doesn't mean it's executable...
>> if this is an AppleScript, though, you may have better luck working
>> with NSAppleScript.
>>
>>> So, thinking that the 'space' maybe wanking out the
>>> 'setLaunchPath' I tried to convert to a 'safe' url path:
>>> NSURL *myScriptFileURL = [NSURL fileURLWithPath:t];
>>> ...
>>> [task setLaunchPath:[myScriptFileURL absoluteString]];
>>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden