Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - telnet

Reply
 
Old 05-25-2009   #1 (permalink)
Bre-x


 
 

telnet

Hi,
How do I close the telnet session?


Dim objShell
Dim strUsername
Dim strPassword

strUsername = "john"
strPassword = "johnpass"

Set objShell=CreateObject("wscript.shell")
objShell.Run "Telnet " & "192.168.0.4"
WScript.Sleep 50
objShell.AppActivate "Telnet " & strComputer

objShell.SendKeys strUsername & "~"
WScript.Sleep 50
objShell.SendKeys strPassword & "~"
WScript.Sleep 50
objShell.SendKeys "su root" & "~"
WScript.Sleep 50
objShell.SendKeys "rootpass" & "~"

objShell.SendKeys "exit" & "~"
objShell.quit

quit???

Thank you all



My System SpecsSystem Spec
Old 05-25-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: telnet


"Bre-x" <cholotron@xxxxxx> wrote in message
news:O3jKUFX3JHA.5816@xxxxxx
Quote:

> Hi,
> How do I close the telnet session?
>
>
> Dim objShell
> Dim strUsername
> Dim strPassword
>
> strUsername = "john"
> strPassword = "johnpass"
>
> Set objShell=CreateObject("wscript.shell")
> objShell.Run "Telnet " & "192.168.0.4"
> WScript.Sleep 50
> objShell.AppActivate "Telnet " & strComputer
>
> objShell.SendKeys strUsername & "~"
> WScript.Sleep 50
> objShell.SendKeys strPassword & "~"
> WScript.Sleep 50
> objShell.SendKeys "su root" & "~"
> WScript.Sleep 50
> objShell.SendKeys "rootpass" & "~"
>
> objShell.SendKeys "exit" & "~"
> objShell.quit
>
> quit???
>
> Thank you all
>
The telnet command "quit" exits telnet.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 05-26-2009   #3 (permalink)
Bre-x


 
 

Re: telnet

I have this script that works ok so far, when the script send the command:
"./john_email.sh" & "~", it is imposible to know how log it will take to
run.
is there a way to "wait" for the command to finish then send the next
command?.

Thank you All

Dim objShell
Set objShell=CreateObject("wscript.shell")

'Connect to Intranet
objShell.Run "Telnet " & "192.168.0.4"
WScript.Sleep 50
objShell.AppActivate "Telnet 192.168.0.4"

'Send telnet User
objShell.SendKeys "john" & "~"
WScript.Sleep 50
objShell.SendKeys "john_pass" & "~"
WScript.Sleep 500

'Send root User
objShell.SendKeys "su root" & "~"
WScript.Sleep 5

objShell.SendKeys "root_pass" & "~"
WScript.Sleep 50

objShell.SendKeys "cd /data/webserver/cron" & "~"
WScript.Sleep 50

objShell.SendKeys "./john_email.sh" & "~"
WScript.Sleep 50

objShell.SendKeys "exit" & "~"
objShell.SendKeys "exit" & "~"
objShell.SendKeys "quit" & "~"




"Bre-x" <cholotron@xxxxxx> wrote in message
news:O3jKUFX3JHA.5816@xxxxxx
Quote:

> Hi,
> How do I close the telnet session?
>
>
> Dim objShell
> Dim strUsername
> Dim strPassword
>
> strUsername = "john"
> strPassword = "johnpass"
>
> Set objShell=CreateObject("wscript.shell")
> objShell.Run "Telnet " & "192.168.0.4"
> WScript.Sleep 50
> objShell.AppActivate "Telnet " & strComputer
>
> objShell.SendKeys strUsername & "~"
> WScript.Sleep 50
> objShell.SendKeys strPassword & "~"
> WScript.Sleep 50
> objShell.SendKeys "su root" & "~"
> WScript.Sleep 50
> objShell.SendKeys "rootpass" & "~"
>
> objShell.SendKeys "exit" & "~"
> objShell.quit
>
> quit???
>
> Thank you all
>

My System SpecsSystem Spec
Old 05-26-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: telnet

From the downloadable help file script56.chm:

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

Note that your method of using the SendKeys command is making your script
unreliable. There are several events that can and will disrupt the SendKeys
method, which is why it should be used only when everything else fails. A
far more reliable method is to use a telnet substitute, sc.exe, which does
not suffer from some of the limitations of telnet, and to embed it in a
batch file. You can get sc.exe from here:
http://www.securityfocus.com/data/tools/nc11nt.zip.


"Bre-x" <cholotron@xxxxxx> wrote in message
news:eY$Ah1h3JHA.4416@xxxxxx
Quote:

>I have this script that works ok so far, when the script send the command:
>"./john_email.sh" & "~", it is imposible to know how log it will take to
>run.
> is there a way to "wait" for the command to finish then send the next
> command?.
>
> Thank you All
>
> Dim objShell
> Set objShell=CreateObject("wscript.shell")
>
> 'Connect to Intranet
> objShell.Run "Telnet " & "192.168.0.4"
> WScript.Sleep 50
> objShell.AppActivate "Telnet 192.168.0.4"
>
> 'Send telnet User
> objShell.SendKeys "john" & "~"
> WScript.Sleep 50
> objShell.SendKeys "john_pass" & "~"
> WScript.Sleep 500
>
> 'Send root User
> objShell.SendKeys "su root" & "~"
> WScript.Sleep 5
>
> objShell.SendKeys "root_pass" & "~"
> WScript.Sleep 50
>
> objShell.SendKeys "cd /data/webserver/cron" & "~"
> WScript.Sleep 50
>
> objShell.SendKeys "./john_email.sh" & "~"
> WScript.Sleep 50
>
> objShell.SendKeys "exit" & "~"
> objShell.SendKeys "exit" & "~"
> objShell.SendKeys "quit" & "~"
>
>
>
>
> "Bre-x" <cholotron@xxxxxx> wrote in message
> news:O3jKUFX3JHA.5816@xxxxxx
Quote:

>> Hi,
>> How do I close the telnet session?
>>
>>
>> Dim objShell
>> Dim strUsername
>> Dim strPassword
>>
>> strUsername = "john"
>> strPassword = "johnpass"
>>
>> Set objShell=CreateObject("wscript.shell")
>> objShell.Run "Telnet " & "192.168.0.4"
>> WScript.Sleep 50
>> objShell.AppActivate "Telnet " & strComputer
>>
>> objShell.SendKeys strUsername & "~"
>> WScript.Sleep 50
>> objShell.SendKeys strPassword & "~"
>> WScript.Sleep 50
>> objShell.SendKeys "su root" & "~"
>> WScript.Sleep 50
>> objShell.SendKeys "rootpass" & "~"
>>
>> objShell.SendKeys "exit" & "~"
>> objShell.quit
>>
>> quit???
>>
>> Thank you all
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
telnet General Discussion
Telnet Vista General
Where did Telnet go? Vista General
Telnet Vista networking & sharing
Telnet Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46