[Lazarus] Lazarus program runs fine in a Terminal but not in a PuTTY session, why?

Bo Berglund bo.berglund at gmail.com
Thu Oct 31 11:06:17 CET 2019


I am working on a program intended to be run by cron in unattended
mode on a Raspberry Pi without GUI installed.

I started it in Windows but have now moved the sources over to
Raspbian for building on that platform and it does not work as
expected...

If I open a terminal window inside the Raspbian GUI (I am using VNC to
work in the GUI) then the test run works as expected.

Right now it is just displaying the content of the directory where the
data will be located using this code as a test:

function TaskReadyToRun(var ID: string): boolean;
var
  FileList: TStringList;
  TaskDir: string;
  i: integer;
begin
  FileList := TStringList.Create;
  try
    TaskDir := DATABASEDIR + '/tasks';
    FindAllFiles(FileList, TaskDir, '*.conf', false);
    if FileList.Count > 0 then
    begin
      for i := 0 to FileList.Count -1 do
        Writeln(FileList[i]);
    end
    else
      Writeln('No files found');
    Result := (FileList.Count > 0);
  finally
    FileList.Free;
  end;
end;

In a termional window on Raspbian I get the expected output.

But when I run the same in a terminal created by PuTTY on my Windows
laptop this is what I see:

pi at rpi4-gui:~/projects/MonitorServer $ ./ssmonitorctrl

(ssmonitorctrl:5436): Gtk-WARNING **: 10:43:42.775: cannot open
display:

Even if I run the program and redirect output to a file I get the same
error message and the listfiles.txt file is empty:

pi at rpi4-gui:~/projects/MonitorServer $ ./ssmonitorctrl > listfiles.txt

What is causing this strange problem?

I thought that Writeln() is the way to send output to stdout, but
maybe not????


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list