[Lazarus] How to get more verbosed output from building

Roland Turcan konf at rotursoft.sk
Thu Mar 19 19:42:55 CET 2009


I need some advice on how to communicate with a ssh server.

I thought that I would take a short cut and use plink to do the donkey
work, just using TProcess to communicate with Plink, and this has
worked, up to a point.

However, it is largely unreliable.

Installing LNet has failed with the error message which says: Error:
Identifier not found "__front_type__"
(v0.9.27 r18951 i386-win32-win32/win64, fpc version 2.2.5 [2009/03/11]).
Similarly Indy has difficulty locating the project files, ICS doesn't
support ssh and Synapse doesn't connect. (Synapse also needs DLLs)

I am writing to Plink like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.SendData(sendstring: string);
begin
  plink.input.write(sendstring[1],length(sendstring));
end;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~


And I am reading from Plink like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function TForm1.readplink: string;
var Buffer: string;
  BytesAvailable:DWord;
  bufsize,BytesRead: integer;
  pC: PChar;
begin
  BytesAvailable := PLink.Output.NumBytesAvailable;
  BytesRead:=0;
  Result:='';
//Sleep(100)<-- If not commented out, some output is retrieved
  while BytesAvailable>0 do
  begin
    SetLength(Buffer, BytesAvailable);
    BytesRead := PLink.OutPut.Read(Buffer[1], BytesAvailable);
    Result:=Result+Copy(Buffer,1,BytesRead);
    BytesAvailable := PLink.Output.NumBytesAvailable;
    NoMoreOutput := false;
  end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I can connect okay, but if I send Plink an instruction:

SendData('cd /opt/myapp'+#10);

But when try to retrieve the output:
  repeat
    NoMoreOutput := true;
    plinkData:=plinkData+readplink;
  until noMoreOutput;

Followed by:
SendData('ls -la'+#10);

and, again, retrieving the output:
  repeat
    NoMoreOutput := true;
    plinkData:=plinkData+readplink;
  until noMoreOutput;

No output is retrieved from PLink.

However, if I put a sleep(100) at the beginning of the readplink
function, then I get some output (but, interestingly, the output from
the first command only appears with the output of the second command).
Also, using the debugger produces another set of results entirely.

This is all far too unpredictable to be of any use to me.

Can anyone give me any advice on this?



More information about the Lazarus mailing list