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

filling a VBS with a list from a TXT file 1

Status
Not open for further replies.

DutchDude

Technical User
Jul 15, 2005
11
NL
good day to all,

I'm seeking help with the following challenge. I would like to fill a VBS script with the variables from a TXT file. My TXT file will have multiple IP addresses, the VBS script should then take every address and use it for the command at line 5 "telnet 192.168.25.230".


'append MAC address to AccesPoint
set WshShell = CreateObject("WScript.Shell")

'Launch telnet session from the command line
WshShell.Run "telnet 192.168.25.230"

'Wait until the application has loaded - Check every second
While WshShell.AppActivate("C:\winnt\system32\telnet.exe") = FALSE
wscript.sleep 100
Wend

'Bring the application to the foreground
WshShell.AppActivate "C:\winnt\system32\telnet.exe"
wscript.sleep 100


afterwards it should restart this whole procedure, but then with the next IP address.

could you give me a hint? [neutral]
 
That's quite a regular thing to do. I'm giving you a purposely twisted shortened and condensed approach. You disassemble it to understand the part.

Each line in the text file contains one ip address, and that the lines are delimited by vbcrlf (carriage return followed by line feed)---that are the assumptions. Else change accordingly.
[tt]
filespec="d:\test\xyz.txt" 'your data file

dim a,s
s=createobject("scripting.filesystemobject").opentextfile(filespec,1,true).readall
a=split(s,vbcrlf)

'append MAC address to AccesPoint
set WshShell = CreateObject("WScript.Shell")

for i=0 to ubound(a)
if trim(a(i))<>"" then
'Launch telnet session from the command line
WshShell.Run "telnet " & a(i)
'follow by all the rest of your lines
end if
next
[/tt]
 
Excellent,

this might be simple for you but I'm just a donkey trying to automate repetitive tasks.

thanks mate.

®
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top