Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


telnet via vbscript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,29832
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> telnet via vbscript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 telnet via vbscript - 1/12/2006 10:58:13 AM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
Here we are, the http://www.visualbasicscript.com/m_29580/tm.htm thread with problems to do .htaccess authenticated login via vbscript seemed to be impossible. Now I'm trying to access into the routers config with telnet via vbscript. The main problem is that I have to start from nothing. Didn't find anything major helps through google either. Does anyone have some kind of basic vbscript source for telnet login with simple get command (received information saved example into a file like C:\log.txt) which I could use like base code and could modify it into my own needs? I would strongly appreciate that.
 
 
Post #: 1
 
 RE: telnet via vbscript - 1/12/2006 10:31:41 PM   
  crazymatt

 

Posts: 287
Score: 0
Joined: 3/4/2005
From:
Status: offline
What do you mean? Do you want to write your own telnet client in vbscript or do you want to use an external telnet client and control it with vbs?

I suggest using a tool like http://www.petri.co.il/software/tst10.zip

This program will let you create a text file with commands, and enter them with your Telnet program.
I've created a text file called reboot.txt and placed it in the TST folder:
10.0.0.138 23
WAIT "User :"
SEND "\m"
WAIT "\m"
SEND "system\m"
WAIT "\m"
SEND "reboot\m"
WAIT "\m"

I then created a shortcut to the TST program:
C:\TST\TST10.exe /r:reboot.txt
(Change the folder location to match your own).

_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to Spewed)
 
 
Post #: 2
 
 RE: telnet via vbscript - 1/13/2006 12:34:24 AM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
Thanks for the advice!

I want to write a vbscript, which uses external telnet client to log in a remote host (adsl router) with admin password and navigate there through the menus to the target submenu, propably using basic SEND commands and get some information using GET commands. How to do that? The information is not necessary to be saved into a file.

Something like this:

      

Althought, the above sample is written with cert, which I don't need and it'ss designed for Vandyke Software's software. So I need a little bit help with this!

(in reply to Spewed)
 
 
Post #: 3
 
 RE: telnet via vbscript - 1/13/2006 2:22:59 AM   
  ziminski

 

Posts: 79
Score: 2
Joined: 1/8/2006
Status: offline
I have used plink, it's a command line telnet tool from putty (free)
see http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html#plink-batch  for docs
then i call it with where clkip.txt is a list of ip addresses, however I have never used it with a router.


'ON ERROR RESUME NEXT
Const ForReading = 1,ForAppending = 8
Set oShell = createobject ("wscript.shell")
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile  ("C:\ClkIP.txt", ForReading)
Set objShell = WScript.CreateObject("WScript.Shell")
strLogFile = "C:\" & Split(WScript.ScriptName, ".")(0) & ".log"
i = 0
Do Until objTextFile.AtEndOfStream
   strNextLine = objTextFile.Readline
   objDictionary.Add i, strNextLine
   i = i + 1
   job=objShell.Run("cmd /c plink.exe -v -ssh -pw user pass@" & strNextLine & " reboot >>s.txt", 0, TRUE)
Loop

(in reply to Spewed)
 
 
Post #: 4
 
 RE: telnet via vbscript - 1/15/2006 9:41:54 PM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
Okay, I made it! I used SendKeys to get into the routers admin interface using PuTTy as a telnet client and save the data through Notepad. I don't think it's the best way to save the data with SendKeys and notepad but it works. Is there a clever way to save spesific rows from the telnet screen into a log file? For example if I want the rows 10,11,14,15 to be saved in the log, how to do it?

The main question is how to hide all the program windows which are used during the script? Is that even possible? Don't want those windows flash on the screen, when running the script. Here's the code:


      

< Message edited by Spewed -- 1/15/2006 9:44:36 PM >

(in reply to ziminski)
 
 
Post #: 5
 
 RE: telnet via vbscript - 1/17/2006 1:27:08 AM   
  Country73


Posts: 710
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
On all of your lines containing "objShell.run" you need to add a little bit to the end.
Example:

    objShell.run "D:\paketit\putt.exe", 0

0 = Hides the window

(in reply to Spewed)
 
 
Post #: 6
 
 RE: telnet via vbscript - 1/17/2006 8:43:05 AM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
Thanks but didn't take an effect. 0 used with Notepad line caused Notepad not to open at all and when opening Notepad after running the script, it continued the Notepad part script by then.

(in reply to Country73)
 
 
Post #: 7
 
 RE: telnet via vbscript - 1/17/2006 6:38:03 PM   
  crazymatt

 

Posts: 287
Score: 0
Joined: 3/4/2005
From:
Status: offline
Err, if you hide notepad it ofcourse wont "start" so you can se it, but it will still be running. Check your taskmanager :D

And the reason your script wont continue is that you are looking for a "window" with the properties for notepad:
Do Until objShell.AppActivate("Untitled - Notepad")
the Application will never be Activated since its hidden, you should look for the process instead or detect it in some other way.

Btw im not sure you can use the sendkey commands to hidden windows. So if you want to hide the whole thing you will prolly have to solve it with some other tools wich dont need sendkey to work.

< Message edited by crazymatt -- 1/17/2006 6:44:59 PM >


_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to Spewed)
 
 
Post #: 8
 
 RE: telnet via vbscript - 1/17/2006 9:26:42 PM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
Yeah, I think so too.

So anyone have a script sample on how to do telnet and save some data into a log file without using an external programs like PuTTY and Notepad? Kind of coding an simple telnet client on vbs.

(in reply to crazymatt)
 
 
Post #: 9
 
 RE: telnet via vbscript - 1/18/2006 8:43:26 AM   
  Spewed

 

Posts: 18
Score: 0
Joined: 1/7/2006
Status: offline
I have solved the problem temporary by switching on the logging from PuTTY, more simple that way and the PuTTY screen flashes so quickly that it doesn't disturb. If someone knows how to do telnet without using external client (simple vbs telnet client) suggestions are welcomed!

(in reply to Spewed)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> telnet via vbscript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts