Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


telnet and logging

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> telnet and logging
  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 and logging - 11/5/2008 8:00:52 AM   
  buck2825


Posts: 14
Score: 0
Joined: 11/5/2008
Status: offline
i have a rather large problem,  the small part that I would like help with here is assigning a value to a variable.  the problem is that the value will be a responce to a command I send to a device, using telnet. 

send message --> ((one line responce)) --> variable.



so far I have and it works great. Thanks to this site.



Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.run "C:\WINDOWS\system32\telnet.exe"
wscript.sleep 500
objshell.sendkeys "open 10.1.0.2"
wscript.sleep 500
objshell.sendkeys "{enter}"
wscript.sleep 500
objshell.sendkeys "some command here {enter}"

'******************************************
'wait for return of text
'assign text to variable
'******************************************

Set objShell = Nothing
WScript.Quit 0

I also have another question if this one gets fixed. :)               




this site is great!!! i have spent the last two day wondering through and have learned more here then I have in a long time.  Thanks!!!!




_____________________________

there are 10 types of people in the world, those that understand binary and those that don't.
 
 
Post #: 1
 
 RE: telnet and logging - 11/5/2008 8:14:18 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
To get the output you would use the .Exec method of the WshShell object. That gives you access to the STDOUT and STDIN for the process.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to buck2825)
 
 
Post #: 2
 
 RE: telnet and logging - 11/6/2008 3:20:21 AM   
  buck2825


Posts: 14
Score: 0
Joined: 11/5/2008
Status: offline
http://msdn.microsoft.com/en-us/library/ateytk4a.aspx

http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspx

while stumbling around this site i cam apon some helpful links regarding the .exec syntax.  If I understand them fully, .exec is good for a single command that would be typed at a "run" promt("windows key" + R). how ever, the system I am inquireing about requires a login and several other commands to get to the point where I send a single command and get back useful data.  sendkeys will get me to the screen and the I can see the data on the cmd window if I send the (for lack of a better term) data query command.  Thats all well and good but that still doesn't put that value into a usable variable that I can pass.

also I must say, i am very impressed with the level of assistance and information avalable on this site.  keep up the good work.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: telnet and logging - 11/6/2008 5:11:13 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
This is definitely not where VBScript shines. You can use VBScript to run  telnet session. It is not particularly robust however and it can get really flaky. You could look at AutoIt which might be a little more robust. If this were my task to do however, I would use powershell. Here is a powershell example:
http://www.leeholmes.com/blog/ScriptingNetworkTCPConnectionsInPowerShell.aspx

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to buck2825)
 
 
Post #: 4
 
 RE: telnet and logging - 11/7/2008 3:34:48 AM   
  buck2825


Posts: 14
Score: 0
Joined: 11/5/2008
Status: offline
thank you very much, I think i'm going to follow another rabbit down a hole. 

_____________________________

there are 10 types of people in the world, those that understand binary and those that don't.

(in reply to ebgreen)
 
 
Post #: 5
 
 
 
  

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 and logging 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