Re: Integrating Unix scripting in Cocoa app
Re: Integrating Unix scripting in Cocoa app
- Subject: Re: Integrating Unix scripting in Cocoa app
- From: Craig Hunter <email@hidden>
- Date: Tue, 07 Aug 2007 16:28:29 -0400
> Message: 10
> Date: Wed, 8 Aug 2007 00:02:29 +1000
> From: Ron Fleckner <email@hidden>
> Subject: Re: Integrating Unix scripting in Cocoa app
> To: Sherm Pendley <email@hidden>
> Cc: Cocoa Dev <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> OK, "launch path not accessible" in the run log. I take back
> everything I said. Obviously I need to rethink this. I would like
> the user to be able to include a script file without having to make
> it executable. Earlier, I had a look to see if there is a way to
> determine whether is file is executable, but didn't find one. I
> suppose there must be a way but didn't see it in NSFileManager or
> NSWorkspace.
Ron,
Take a look at the shell's "source" command, which will load and execute
commands from a text file with no other requirements:
source file.txt
This might give you an additional option. Perhaps you can check to see if
the file is executable and/or if it includes the shebang. If not, then
conclude it's merely a text file containing shell commands and pass it along
to "source" to run.
But here's something interesting: according to a simple "hello world" script
I just tested, source will even handle text files that have execute
permission set and contain a shebang (ie, real scripts). If that turns out
to be true in general, then you can let the source command execute anything
designated as a script by the user. I'd recommend testing it out.
Craig
--
Dr. Craig Hunter
NASA Langley Research Center
Configuration Aerodynamics Branch
email@hidden
(757) 864-3020
_______________________________________________
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