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