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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read In/Read Out 1

Status
Not open for further replies.

NetNodeMan

Technical User
Mar 30, 2005
65
IE
Folks,

I'm trying to create a script that will read in an IP address from a text file. I'm finding a search on this forum is bringing up very little.

The ip address will be telnetted to and the output of this will be printed to a log file. How do I capture this output also?


Complete newbie here so thanks in advance.
 
if you want to read from a text file then FSO.OpenTextFile
.ReadAll or .ReadLine

for reading the output of a command then you might like to try WshShell.Execute(telnet...., this can be read in the same way as a TextStream
 
????

Sorry movie. A slight bit lost there:


Here's my code. I want to output the sh run command


set oShell=CreateObject("WScript.Shell")

oShell.Run "telnet 137.223.5.49", 9
WScript.sleep 500

oShell.Sendkeys "Traverse{ENTER}"
WScript.sleep 500

oShell.Sendkeys "V3rySecure!${ENTER}"
WScript.sleep 500


oShell.Sendkeys "sh ver{ENTER}"
oShell.Sendkeys "m" ----This is for the "more" command. How do I enter a SPACE?
WScript.sleep 500



oShell.Sendkeys "exit{ENTER}"
wscript.sleep 500

oShell.Sendkeys "m"

oShell.Sendkeys "{ENTER}"












'Need a sleep statment or script will try and read
'the buffer before its full.
wscript.sleep 800

'Save the output to a string for general use
'sBuf = s.read
'wscript.echo sBuf


 
sorry the Exec method is what you want


Exec Method
Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.

object.Exec(strCommand)
Arguments
object
WshShell object.
strCommand
String value indicating the command line used to run the script. The command line should appear exactly as it would if you typed it at the command prompt.
Remarks
The Exec method returns a WshScriptExec object, which provides status and error information about a script run with Exec along with access to the StdIn, StdOut, and StdErr channels. The Exec method allows the execution of command line applications only. The Exec method cannot be used to run remote scripts. Do not confuse the Exec method with the Execute method (of the WshRemote object).
 
haha

Completely lost - thanks for your time mrmovie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top