Home > Back-end >  Consult delphi7 Windows 7 environment, use Doscommand controls plink, SSH login server problem
Consult delphi7 Windows 7 environment, use Doscommand controls plink, SSH login server problem

Time:09-17

I rookie, using delphi7 + Windows 7 environment, use the + plink Doscommand controls do a SSH login server program, the program take steps (as follows), encounter a problem, perform the first piece of code well, is not the first piece of code executed when performing a second code window input characters, but also open a window, after the program execution, in the task manager can see eight plink process and 8 conhost console window host, equals eight open the window, if it will be the first line replacement for s:='CMD/c putty - load 123-111111 [email protected] pw', you can see is indeed eight opened the window, not in a window under continuous execution, consult everybody the teacher, how to within the same window (window) is the first piece of code generated continuously input characters to execute a program,

//step 1 log in, after the success of the login into the menu options
S:='plink - SSH - pw 111111 [email protected];//the default port 22 SSH
Memo1. Lines. The Clear;
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
Doscommand1.Com mandLine:=s;
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 2 select menu press 1
Memo1. Lines. The Clear;
S:='1';
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 3 enter the IP, according to the IP query equipment
Memo1. Lines. The Clear;
S:='/I: 10.10.15.26';
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//choose to login equipment according to the step 4 1
Memo1. Lines. The Clear;
S:='1';
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 5 command options, press 1, automatically enter the Telnet (port 23)
Memo1. Lines. The Clear;
S:='1';
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 5 command options, press 1, automatically enter the Telnet (port 23)
Memo1. Lines. The Clear;
S:='1';
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 6 input Telnet user name
Memo1. Lines. The Clear;
S:='WWW'.
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 7 type Telnet password
Memo1. Lines. The Clear;
S:='123456'.
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;
//step 8 input Telnet command
Memo1. Lines. The Clear;
S:='show MAC;
Memo1. Lines. The Add (' current command + s + 'return results');
Memo1. Lines. The Add (");
DosCommand1. SendLine (s, true);
Doscommand1. OutputLines:=Memo1. Lines;
DosCommand1. Execute;

CodePudding user response:

Step 5: when you copy and paste to repeat the above code

CodePudding user response:

Can't change ideas adopted the focus of hidden window open window to simulate keyboard input way
Winexec (' the putty - load 123 - pw 111111 [email protected], sw_hide);
H:=findwindow (nil, '123');
S:='1';
For I:=1 to length (s) do the begin
The SetForegroundWindow (h);
SwitchToThisWindow (h, true);
[I] MyKeyPress (s);
end;
Keybd_event,0,0,0 (13);
KEYEVENTF_KEYUP keybd_event (13, 0, 0).

A good way to please inform thank you
  • Related