[Lazarus] TProcess 2-way conversation
Burkhard Carstens
fpc at bcsoft.de
Fri Mar 13 13:24:54 CET 2009
Am Freitag, 13. März 2009 12:23 schrieb Dave Coventry:
> Hi,
>
> I'm writing a quick an dirty app to automate some commands which
> would normally be issued by a terminal something like PuTTy.
>
> To do this I'm using TProcess to call plink.exe and then trying to
> ssh into the remote box and issue commands.
>
> In short I want to log into the remote box and execute commands 'cd
> /opt/someappdir' and './someapp', taking the input through one memo
> and using another memo to issue the commands.
>
> Can anyone point me in the right direction? I can open the terminal:
>
> PLink.CommandLine := 'plink.exe -ssh -pw
> '+options.Values['Password']+' -batch
> '+options.Values['User']+'@'+options.Values['Server'];
> but sending subsequent calls fail:
> PLink.CommandLine := 'cd /opt/someappdir/ta';
>
> Error message: 'Failed to execute cd /opt/someappdir/ta'
Your process is plink.exe. any further communication should go through
plink.input and plink.output, e.g. (not tested):
...
plink.execute;
{ read welcome message from plink.output }
remoteCommand:='cd /opt/someappdir/ta'#10;
plink.input.write(remoteCommand[1],length(remoteCommand));
{ read (echo and?) result of previous command}
regards
Burkhard
More information about the Lazarus
mailing list