Quote:
> Is it possible to write a script that will initiate a telnet session,
> execute commands in the telnet session, and then close the telnet
> session?
I see you found the telnet component, but may I suggest another approach?
Using ToolSack Baseline <http://www.toolsack.com/> or any other component,
simply open a socket to port 23 of the host. Example script below. This
approach has one advantage over the telnet window approaches: it can be
launched by a service process.
function ReadSome(s)
dim n,str
n = 0
do while n < 5
if s.CountDataAvailable = 0 then
n=n+1
else
str = str & s.ReadAmount(s.CountDataAvailable)
n = 0
end if
wscript.sleep 100
loop
ReadSome = str
end function
function hostLogin(cHost,cUsername,cPass)
set s = CreateObject("Toolsack.Socket")
wscript.echo "Connecting ..."
s.Connect cHost,23
wscript.echo "connected"
wscript.echo "reading..."
wscript.echo ReadSome(s)
wscript.echo "writing..."
s.Write cUserName & vbCR
wscript.echo "reading..."
wscript.echo ReadSome(s)
wscript.echo "writing..."
s.Write cPass & vbCR
wscript.echo "reading..."
wscript.echo ReadSome(s)
wscript.echo "writing..."
s.Write "touch I.logged.in.here; logout"
wscript.echo "reading..."
wscript.sleep 500
wscript.echo ReadSome(s)
s.close()
end function