posixscript(
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.

See Also

- applescript -- executes an AppleScript.
- applescript( -- executes AppleScript source code and returns the result.
- blindposixscript( -- executes a POSIX shell script using NSTask and returns the process id.
- executeapplescript -- compiles and runs an AppleScript.
- executeperlscript -- executes Perl code.
- executesudounix -- executes a UNIX shell command using *sudo* (root) privileges.
- executeunix -- executes a UNIX shell command.
- info("posixtasks") -- list of POSIX shell tasks running in the background.
- perl -- executes a Perl script (program).
- perl( -- executes a perl program and returns the result (stdout).
- php -- executes a PHP script (program).
- php( -- executes a PHP program and returns the result.
- posixtask -- executes a POSIX shell script in the background using NSTask.
- posixtask( -- executes a POSIX shell script in the background using NSTask.
- python -- executes a Python script (program).
- python( -- executes a python program and returns the result (stdout).
- ruby -- executes a Ruby script (program).
- ruby( -- executes a ruby program and returns the result (stdout).
- scriptbglog -- specifies a path/file for output from STDOUT from embedded programs run in the background (Perl, Ruby, Python, PHP).
- Scripting Language Configuration -- configuring the scripting languages available to Panorama (Perl, PHP, Python and Ruby).
- scripttimeout -- sets the maximum runtime allowed for an embedded program (AppleScript, ShellScript, Perl, Ruby or Python).
- shellscript -- executes a UNIX shell script.
- shellscript( -- executes a UNIX shell script and returns the result.
- stopposixtask -- stops a POSIX shell script that is running in the background.
- usebashprofile -- grabs the search path from the `.Bash_profile` file in the user's home folder, so that these paths will be used by scripting languages (*Ruby, Python*, etc.).
- xcallbackurl -- performs an action in another application using the x-callback-url mechanism.

History

Version | Status | Notes
10.2 | New | New in this version.