Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling Telnet session using VBScript

Status
Not open for further replies.

Yogalakshmi

Programmer
Feb 28, 2007
3
US
Hi,

I am new to this scripting world, i am facing some problem while executing a similar script as described in this thread...

I have to lauch telnet to execute some Unix commands, while searching for the answer, by luck i have seen this tread ASendKeys problem... and it is quite useful also... but while i am trying to execute the script,

its throwing the message as Object required:'WScript'

Script:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "CMD.EXE /K telnet unix"
WshShell.AppActivate "telnet racerx"
WScript.Sleep 100000
WshShell.AppActivate "telnet unix"
WshShell.Wscript.Sleep 10000
WshShell.Sendkeys username
WshShell.AppActivate "telnet unix"
WshShell.Sendkeys "~"
WshShell.AppActivate "telnet unix"
WScript.Sleep 100000
WshShell.AppActivate "telnet unix"
WshShell.Sendkeys pwd
WshShell.Sendkeys "~"

Thanks in Advance,
Yoga
 
Object required:'WScript'
your code should be in a .VBS file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,

thanks for ur replies...

and i am not facing any problem with Sendkey... WScript is not getting identified as an object at all...

and i have tried by saving that file as .vbs only... but still i got that msg...

-Yoga
 
Well this line looks wrong
WshShell.Wscript.Sleep 10000

Should just be
Wscript.Sleep 10000

Code:
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "CMD.EXE /K telnet unix"
WshShell.AppActivate "telnet racerx"
WScript.Sleep 100000
WshShell.AppActivate "telnet unix"
Wscript.Sleep 10000
WshShell.Sendkeys username
WshShell.AppActivate "telnet unix"
WshShell.Sendkeys "~"
WshShell.AppActivate "telnet unix"
WScript.Sleep 100000
WshShell.AppActivate "telnet unix"
WshShell.Sendkeys pwd
WshShell.Sendkeys "~"

and like PHV stated, make sure it is in a .vbs file.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
What script host are you using?

Is this a WSH script or a script in an HTA or HTML page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top