shellscript(
SOURCE
)

The shellscript( function executes a UNIX shell script 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 UNIX shell script and returns the result. This example uses the ls command to list the files in the user library folder.

shellscript({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.

Panorama formulas can be embedded in the script using special tags. To embed a Panorama formula use

$«formula»$

The formulas are calculated in advance, then embedded into the source code as constants. For example, the formula $«2*3»$ will be embedded into the program as 6. The formula $«upper("hello world")»$ will be embedded as HELLO\ WORLD. Note: You can embed database fields, global variables, fileglobal variables, and windowglobal variables into the formula, but local variables will not work. (You can, however, use local variables with the shellscript statement.)

In the case of text formulas any special characters will be encoded as necessary for a proper shell script literal. For example the formula $«{"}»$ will be embedded as ".

To embed a Panorama formula with no quotes or translation use

^«formula»^

Note: This function is similar to the posixscript( function, but with some significant differences. When using the posixscript( function, no substitutions are performed on the script code, so you cannot embed Panorama variables and formulas into the code as described above (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) while the shellscript( function uses AppleScript, so the posixscript( function is faster. The shellscript( function is retained for compatibility with legacy database applications, but posixstring( is recommended for new applications.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0.