Re: [twsocket] TnEmulVT automation

2005-09-14 Thread Stadin, Benjamin
I've written something like this a few years ago. I don't advertise this any
longer, you can have a free copy or parts of the code if you wish.
Description is on http://homepages.fh-giessen.de/~hg12799
Contact me out of the list.

GetCmd below get's the position of a command within a script. I parse a
script line by line and when a command (html like in <> brackets) is the
next part of the line, DoCmd is called which executes the command. 
I think you can exchange or add the string you wish to respond to in getcmd,
so just add a command without brackets if what you want is to just respnd to
a command line from the terminal. 

Looking back, it's propably the worst spaghetti code I've ever written ;-).
But it's surprisingly still working ok in the environment I've written it
for (backup of about 150 network devices several times a day and recovery)


Benjamin Stadin


function TBenScript.GetCmdPos(LineString: String): Integer;  // Führt
Kommando aus und liefert StringPosition des Kommandos
var CmdPos: Integer; // erstes Kommando in Zeile
ThisPos: Integer;  // aktuelle geparsetes Kommando
  //  FirstCommand parsed welches abgeklapperte Kommando das erste ist
begin
  CmdPos := 0; // Kein Vorgängerwert von Pos = logisch 0 für Result
  FirstCommand := '';
  NoReturn := False;
  CmdLength := 0;

if Pos('',Uppercase(LineString)) > 0 then begin
 CmdPos := Pos('',Uppercase(LineString));
 FirstCommand := '';
 NoReturn := True; // NoReturn = dieser befehl braucht keinen return,
wird aus scriptline entfernt
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 CmdPos := Pos('',Uppercase(LineString));
 FirstCommand := '';
 NoReturn := True;
end;

if Pos(' 0 then begin
 CmdPos := Pos('',ScriptLine);
 FirstCommand := '',Uppercase(LineString)) > 0 then begin
 CmdPos := Pos('',Uppercase(LineString));
 FirstCommand := '';
 hauptform.telnet.WriteStr(RetSeq);
  //   NoReturn := True;
  // hier nicht, weil emulvt erst nach zeichenübergabe FSave2File ändert 
end;

if Pos(' 0 then begin
 CmdPos := Pos('',ScriptLine);
 FirstCommand := '',Uppercase(LineString)) > 0 then begin
 CmdPos := Pos('',Uppercase(LineString));
 FirstCommand := '';
 NoReturn := True;
end;

if Pos('',Uppercase(LineString)) > 0  then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',LineString);
  FirstCommand := '';
  NoReturn := True;
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
  NoReturn := True;
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
  NoReturn := True;
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
  NoReturn := True;
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
  NoReturn := True;
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin
  CmdPos := Pos('',Uppercase(LineString));
  FirstCommand := '';
 end;
end;

if Pos('',Uppercase(LineString)) > 0 then begin
 ThisPos := Pos('',Uppercase(LineString));
 if (ThisPos < CmdPos) or (CmdPos = 0) then begin

Re: [twsocket] TnEmulVT automation

2005-09-14 Thread Francois Piette
Have a look at TTnScript component. It is derived from TTnEmulVT and add some 
[limited] scripting
capabilities. See the doc in the comments in front of component source code.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


- Original Message - 
From: "Artem Antonov" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Wednesday, September 14, 2005 12:26 PM
Subject: [twsocket] TnEmulVT automation


> Hello!
>
> The question is: how I can send username and pasword on connection
> with Telnet server without printing them on console, i.e. somethink
> like script?
>
> Thanks.
>
> Best regards,
> Artem Antonov.
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be