blindposixscript(
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

- applescript -- executes an AppleScript.
- applescript( -- executes AppleScript source code and returns the result.
- 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.
- posixscript( -- executes a POSIX shell script using NSTask 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.