Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3   9.4    Statistic  

RunTask.Launch

Launches the task represented by the receiver.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
RunTask 3.1 Yes Yes Yes No No
MBS( "RunTask.Launch" )   More

Parameters

none

Result

Returns OK or error.

Description

Launches the task represented by the receiver.
If you get back an error with posix_spawn and error 13, that's a permission denied.

Please use Shell.Execute if you need more features.

For PowerShell scripts on Windows, you may need to check with the execution policy for the user account FileMaker is using or use an admin account. e.g. on FileMaker Server, may need to be installed as Admin user (not fmserver user).

Examples

Run ls on Mac:

# new task
Set Variable [$r; Value:MBS( "RunTask.NewTask" )]
#set launch path and arguments
Set Variable [$r; Value:MBS( "RunTask.SetLaunchPath"; "/bin/ls" )]
Set Variable [$r; Value:MBS( "RunTask.SetArguments"; "/bin" )]
# run
Set Variable [$r; Value:MBS( "RunTask.Launch")]
# wait
Loop
    Pause/Resume Script [Duration (seconds): ,1]
    Exit Loop If [MBS( "RunTask.IsRunning" ) ≠ 1]
End Loop
# read result
Set Variable [$data; Value:MBS( "RunTask.ReadOutputText"; "UTF-8" )]
Show Custom Dialog ["Result"; $data]

List connected clients on FileMaker Server:

# © 30.07.2016 Patrick Weh | Team Nifty GmbH (17:40 Uhr)
# List connected Clients
# ------------------------------------------------------------------------------------------------------------
# Script checks for connected clients at the FileMaker Server.
# Copy this File to your Server and run this Script on your FileMaker Server.
# ------------------------------------------------------------------------------------------------------------
#
Set Error Capture [On]
Allow User Abort [Off]
#
Set Variable [$r; Value:MBS( "RunTask.NewTask" )]
Set Variable [$r; Value:MBS( "RunTask.SetLaunchPath"; "/Library/FileMaker Server/Database Server/bin/fmsadmin" )]
# please put your admin password here
Set Variable [$r; Value:MBS( "RunTask.SetArguments"; "-u" ; "fmserveradmin" ; "-p" ; "fmserveradminpassword" ; "list" ; "clients" ; "-s" )]
Set Variable [$r; Value:MBS( "RunTask.Launch")]
# now wait for task to finish:
Set Variable [$result; Value:""]
Loop
    Pause/Resume Script [Duration (seconds): 2]
    Set Variable [$result; Value:$result & MBS("RunTask.ReadOutputText")]
    Exit Loop If [MBS("RunTask.IsRunning") ≠ 1]
End Loop
#
# write into a field:
Set Field [Check clients::Clients; $result]
Commit Records/Requests [No dialog]
#

Run shell script in bash:

Set Variable [$r; Value:MBS( "RunTask.NewTask" )]
Set Variable [$r; Value:MBS( "RunTask.SetLaunchPath"; "/bin/bash" )]
Set Variable [$r; Value:MBS( "RunTask.SetArguments"; "/Users/cs/Desktop/test.sh"; "First Param" )]
Set Variable [$r; Value:MBS( "RunTask.Launch")]

Run something with shell to do redirect:

Set Variable [ $r ; Value: MBS( "RunTask.NewTask" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.SetLaunchPath"; "/bin/bash" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.SetArguments"; "-c"; "date >/tmp/date.txt" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.Launch") ]
Loop
    Pause/Resume Script [ Duration (seconds): ,1 ]
    Exit Loop If [ MBS( "RunTask.IsRunning" ) ≠ 1 ]
End Loop
Set Field [ RunTask::Text ; MBS( "Text.ReadTextFile"; "/tmp/date.txt"; "UTF-8" ) ]

Show quicklook preview window for PDF file:

Set Variable [ $r ; Value: MBS( "RunTask.NewTask" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.SetLaunchPath"; "/usr/bin/qlmanage" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.SetArguments"; "-p"; "/Users/cs/Desktop/Hello World.pdf" ) ]
Set Variable [ $r ; Value: MBS( "RunTask.Launch") ]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 28th June 2019


RunTask.IsRunning   -   RunTask.NewTask

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins