[Lazarus] TProcess 2-way conversation
Dave Coventry
dgcoventry at gmail.com
Fri Mar 13 23:32:14 CET 2009
Hi Vincent,
2009/3/13 Vincent Snijders <vsnijders at vodafonevast.nl>:
> See the process example:
>
> http://wiki.lazarus.freepascal.org/Executing_External_Programs#Using_input_and_output_of_a_TProcess
> and
> https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/examples/process/
>
> Vincent
That was the article on which I based my code.
I'm not having much luck.
PLink.CommandLine := plink.exe -ssh -pw
'+options.Values['Password']+' -batch
'+options.Values['User']+'@'+options.Values['Server'];
Plink.Options := [poUsePipes];
Memo1.Append('-- executing --');
PLink.Execute;
M.SetSize(BytesRead + READ_BYTES);
n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
if n > 0 then
begin
S.LoadFromStream(M);
for i:=0 to S.Count-1 do
begin
Memo1.Lines.Append(S[i]);
end;
end
else
begin
Memo1.Lines.Append('Unable to open '+options.Values['Server']);
end;
remoteCommand:='ls -l'+#10;
plink.input.write(remoteCommand[1],length(remoteCommand));
M.SetSize(BytesRead + READ_BYTES);
n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
if n > 0 then
begin
S.LoadFromStream(M);
for i:=0 to S.Count-1 do
begin
Memo1.Lines.Append(S[i]);
end;
end;
I would expect the output of 'ls -l' to give me quite a lot of
information but S.LoadFromStream(M); doesn't contain anything at all.
More information about the Lazarus
mailing list