posixscript(
SOURCE
)

The posixscript( function executes a POSIX shell script using NSTask and returns the result.


Parameters

This function has one parameter:

source – UNIX shell script (source code). Note: It is very convenient to use “pipe” delimiters for this parameter, for example |||script|||. This eliminates needing to worry about the delimiters that occur in the script itself..


Description

This function executes a POSIX shell script using NSTask. This example uses the ls command to list the files in the user library folder.

posixscript({cd ~/Library;ls -l})

The result will be something like this:

total 1976
drwxr-xr-x     5 jimrea  staff      170 Apr  6  2005 Acrobat User Data
drwx------     2 jimrea  staff       68 Dec 15  2003 Address Book Plug-Ins
drwxr-xr-x   126 jimrea  staff     4284 Aug 19 13:44 Application Support
drwx------     2 jimrea  staff       68 Oct 14  2003 Assistants
drwx------     6 jimrea  staff      204 Feb  4  2006 Audio
drwxr-xr-x    15 jimrea  staff      510 Aug  3 23:51 Automator
drwxr-xr-x     2 jimrea  staff       68 May  1  2005 Autosave Information
drwxr-xr-x     3 jimrea  staff      102 Feb 21  2007 Bundles
drwx------   171 jimrea  staff     5814 Aug 30 09:44 Caches
drwxr-xr-x     2 jimrea  staff       68 Jul 13 21:48 Calendars
drwxr-xr-x     3 jimrea  staff      102 May  1  2005 Classic
drwx------     7 jimrea  staff      238 May 26 17:00 ColorPickers
drwxr-xr-x     3 jimrea  staff      102 Jan 23  2006 ColorSync
...

There are hundreds of different shell commands available. Describing all of these commands is beyond the scope of this documentation, but there are many books available, as well as numerous web resources.

Note: This function is similar to the shellscript( function, but with some significant differences. Unlike the shellscript( function, no substitutions are performed on the script code, so you cannot embed Panorama variables and formulas into the code (of course you can use a formula to build the code any way you want). Most importantly, the posixscript( function runs the script by using a native Cocoa method (NSTask) instead of via AppleScript, so it is faster. The shellscript( function is retained for compatibility with legacy database applications.


Error Messages

POSIX SCRIPT ERROR – If the script encounters a runtime error, the posixscript( function will generate an error.


History

VersionStatusNotes
10.2NewNew in this version.