Re: Integrating Unix scripting in Cocoa app
Re: Integrating Unix scripting in Cocoa app
- Subject: Re: Integrating Unix scripting in Cocoa app
- From: Andrew Farmer <email@hidden>
- Date: Tue, 7 Aug 2007 13:42:55 -0700
On 07 Aug 07, at 13:28, Craig Hunter wrote:
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.
There's something wrong with your test script. 'source' performs no
such interpretation; it simply loads the file as a shell script into
the running shell. Try it with the following Python script, for example:
#!/usr/bin/env python
import sys
print repr(sys.argv)
On most systems, this'll fail with "import: command not found". If
you've got ImageMagick installed, it'll do even stranger things.
_______________________________________________
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