Script a telnet session 
Author Message
 Script a telnet session

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 have been unable to find any support on how to manage a telnet session
thru a script.

Any help would be greatly appreciated.

TIA

Charles



Mon, 25 Jul 2005 00:57:18 GMT  
 Script a telnet session
Found a utility from a previous post.  The link is below.  Already have it
working and it's great.  Only thing I could not find is the command to close
the Tel window when the script is complete (or am I supposed to just run the
Tel.minimized?)

Charles



Quote:

> http://groups.google.com/groups?threadm=ei33Q0efCHA.1724%40tkmsftngp11

> --
> Please respond in the newsgroup so everyone may benefit.
>  http://dev.remotenetworktechnology.com
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>  http://www.microsoft.com/technet/security/bulletin/notify.asp



> > I heard this is now possible, but just want a basic vb
> > script that will connect to a host, run a command or two
> > based upon the screen and then logout.

> > I can't believe I have such a hard time finding something
> > that is so basic.

> > If VB can't do it I've tried several shareware / CVTerm
> > etc.. but I can't find anything freeware...

> > times are tough now adays and I can't use shareware on the
> > job..

> > thanks



Mon, 25 Jul 2005 03:04:26 GMT  
 Script a telnet session


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



Mon, 25 Jul 2005 05:04:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Script a telnet session

2. scripting a telnet session ?

3. script to able telnet session

4. Is there a way of scripting Telnet sessions ?

5. Automate a telnet session

6. Open Telnet Session

7. Automating a telnet session.

8. Howto open a telnet session from vbscript

9. Automate a telnet session

10. Automating a telnet session.

11. Open Telnet Session

12. Source code for telnet session ??

 

 
Powered by phpBB® Forum Software