Re: Telnet using vbscript (or similar) by sali
sali
Mon Jan 03 01:55:07 CST 2005
"CoachHog" <CoachHog@hotmail.com> wrote in message
news:lk3ht01mm9nm4habi92ms7kp3vjtecejjv@4ax.com...
> Simple question...
>
> Is there a way to telnet into (passing user name and password info)
> into a unix computer, and launch a program from within a vbscript?
>
> I was thinking the winsock.dll should be able to provide connection
> functionality but I can't find any information regarding the use of
> the dll with vbscript.
>
> I'm trying to stay away from using Visual Basic or writting my own C++
> project.
>
try "wshScriptExec" object, here is a snippet from doc.
you need script engine at least 5.6.
when you create "exec" object, you effectively run some application, but
having
*full* acces to its "stdion" and "stdout", so you may control it
programaticaly from
script like you are typing directly from keyboard.
"telnet" should be a *perfect* example for it!
-------------------------
Dim WshShell, oExec, input
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("test.bat")
input = ""
Do While True
If Not oExec.stdout.AtEndOfStream Then
input = input & oExec.stdout.Read(1)
If InStr(input, "Press any key") <> 0 Then Exit Do
End If
WScript.Sleep 100
Loop
oExec.StdIn.Write VbCrLf
Do While oExec.Status <> 1
WScript.Sleep 100
Loop
-------------------------------