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'
If I omit the subsequent calls it works roughly as expected:
Plink.Options := [poUsePipes];
Memo1.Append('-- executing --');
Screen.Cursor:=crHourGlass;
PLink.Execute;
M.SetSize(BytesRead + READ_BYTES);
n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
if n > 0
then begin
S.LoadFromStream(M);
Memo1.Append(S.Text)
end;
S.Free;
M.Free;and I get the following in memo1:
-- executing --
Last login: Fri Mar 13 02:49:21 2009 from 192.168.37.43
Y?J??9?a?f??/F?#2??/??Y.KDPx?R?`?8?\.ow?z%
Can anybody suggest something here? Or point me in a better direction.
