[SOLVED]Getting AppleScript output lazarus / 15-macOS - Mac OS X ---------------------------------------------------------------------- bobix · 2017-04-21 10:37 Does anyone knows how to get AppleScript's output? I am trying this way, but getting empty string: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,process; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  ss:string;begin  runcommand('osascript ''return "hello world"''',ss);  showmessage(ss);end; end. ---------------------------------------------------------------------- Phil · 2017-04-21 13:30 Quote from: bobix on April 21, 2017, 12:37:46 pmDoes anyone knows how to get AppleScript's output? Perhaps RunCommand can't find the executable to run unless you include a path to it. See if what you're trying to do works with other command line programs, eg, ls. osascript is probably in /usr/bin. Note that the form of RunCommand you're using is deprecated. I usually just use TProcess instead of functions that attempt to simplify TProcess by wrapping it. http://www.freepascal.org/docs-html/fcl/process/runcommand.html ---------------------------------------------------------------------- bobix · 2017-04-21 13:57 Thank you! It think i have found a solution, but have to test it on Monday. I will give a feedback if it works ---------------------------------------------------------------------- bobix · 2017-04-26 13:49 Working code. Same as Linux one Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     procedure TForm1.Button1Click(Sender: TObject);    var      AProcess: TProcess;      AStringList: TStringList;    begin      AProcess := TProcess.Create(nil);      AProcess.Executable := '/bin/sh';      AProcess.Parameters.Add('-c');      AProcess.Parameters.Add('echo `ls`');      AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];      AProcess.Execute;      AStringList := TStringList.Create;      AStringList.LoadFromStream(AProcess.Output);      showmessage(astringlist.Text) ;      AStringList.Free;      AProcess.Free;    end;