FileMaker Server 上での Script デバッグの補助
FileMaker Server の Documents フォルダの CustomScriptErrors.log に値を追記
PowerShell で CustomScriptErrors.log を監視、新しいログを「MeowNotify」へ送信
FileMaker
スクリプト: add_ScriptErrors(Log)
変数を設定 [ $Log; 値:Get(スクリプト引数) ]If [ IsEmpty ( $Log ) ]現在のスクリプト終了 [ ]End If変数を設定 [ $Log; 値:$Log & Char ( 9 ) & Get ( アプリケーションバージョン ) ]変数を設定 [ $fileName; 値:"CustomScriptErrors.log" ]変数を設定 [ $file; 値:Get (ドキュメントパス) & $fileName ]ファイルの存在を取得 [ 「$file」 ; ターゲット: $fileExists ]If [ $fileExists=0 ]データファイルを作成 [ 「$file」 ; フォルダを作成: オン ]End Ifエラー処理 [ オン ]ファイルサイズを取得 [ 「$file」 ; ターゲット: $fileSize ]データファイルを開く [ 「$file」 ; ターゲット: $fileID ]データファイルの位置を設定 [ ファイル ID: $fileID ; 新しい位置: $fileSize ]データファイルに書き込む [ ファイル ID: $fileID ; データソース: $Log ; 書き込み: UTF-8 ; 改行を追加: オン ]データファイルを閉じる [ ファイル ID: $fileID ]PowerShell
MonitorScriptErrorsLog.ps1
function Send-Text($Text) { $remoteIPstr = '192.168.100.180'; <#通知を受け付けるPCのIPアドレス#> $Port = 50210; $remoteIP = [System.Net.IPAddress]::Parse($remoteIPstr); $endpoint = New-Object System.Net.IPEndPoint ($remoteIP, $Port); $udpclient = New-Object System.Net.Sockets.UdpClient; $bytes = [Text.Encoding]::UTF8.GetBytes($Text); $bytesSent = $udpclient.Send($bytes, $bytes.length, $endpoint); $bytesSent | Out-Null; $udpclient.Close();}プログラム/スクリプト: powershell
引数の追加: -NoProfile -ExecutionPolicy Unrestricted .\MonitorScriptErrorsLog.ps1
開始(オプション): C:\Users\PCUSER\Documents\Script
※「開始(オプション):」は、MonitorScriptErrorsLog.ps1 のあるディレクトリを設定