blindposixscript(
SOURCE
)

The blindposixscript( function executes a POSIX shell script using NSTask and returns the process id.


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. Unlike the similar posixscript( function, the script operates completely independently of Panorama. Panorama does not wait for the script to finish, and the script could even continue running after Panorama has quit. Since the function does not wait for the script to finish, the function cannot receive the output from the script. Hence the “blind” designation – the script can perform operations but Panorama cannot find out the result of those operations (unless the script redirects output to a file.)

The function does return the process ID number of the script. With this number you can use the runningappinfo( function to monitor the script.

Here is an example that forces Panorama to quit and then immediately relaunch. (Panorama uses a variation of this code to install updates.)

let executablePath = posixpath(replace(bundleresourcepath(),".app/Contents/Resources",".app"))
let relaunchScript =
    // force Panorama to quit
    "kill -9 "+info("processidentifier")+lf()+
    // wait for Panorama to stop
    "while ps -p "+info("processidentifier")+"; do sleep 1;done;"+lf()+
    // re-open Panorama
    "open "+ executablePath
let pid = blindposixscript(relaunchScript)

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 (but like the posixscript( 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 blindposixscript( 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.


See Also


History

VersionStatusNotes
10.2NewNew in this version.