Let me preface this post by stating that I have never programmed in VB
before. That said...

I am working on a script that involves some telneting. From what I
could find, scripting isn't available for command line inputs to
Microsoft's telnet. So I found an alternative here:

http://www.freewarefiles.com/program_10_112_3879.html

It's a VB script that has its own telnet program that IS scriptable.
It comes with a Tel.vbs file which can be edited and run as a telnet
script. I can get everything to work great except for one feature I
want to add. By default, this script takes the IP address from
arguments in the shortcut properties (if you download and install this
program, you will see this in the Tel.vbs code). I want to program the
script to read a text file to obtain the IP address to which it will
connect.

Any suggestions?

Re: Reading from a file by trading_jacks

trading_jacks
Mon Oct 16 14:03:06 CDT 2006

First change the code to this:
you won't have to change the shortcut at all, it will just now ignore
that argument. you could remove those lines and delete the argument
from the shortcut if you wanted.
-----------------------------------------
dim args
Dim HostName
Dim NotUsed
Dim Port
Dim UserName
Dim Password
dim StartPath

Set args = WScript.Arguments

if (args.Count < 4) then
NotUsed = ""
Port = ""
UserName = ""
Password = ""
StartPath = ""
else
NotUsed = args.Item(0)
Port = args.Item(1)
UserName = args.Item(2)
Password = args.Item(3)
if (args.Count = 5) then
StartPath = args.Item(4)
end if
end if
--------------------------------------------------------

now add something like the following
**********************************
Reading Text File
**********************************
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\servers.txt", ForReading)

HostName = objTextFile.ReadLine

objTextFile.Close

that will set HostName as the first line in the text file.

That should get you off and running.


Re: Reading from a file by tr0y

tr0y
Mon Oct 16 14:08:24 CDT 2006

Try this:

Create at text file named inputfile, add your ip addresses one per line
and save file then add the below code to the script you want to use.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("inputfile.txt", 1)

Do until oFile.AtEndOfStream

strInput = oFile.ReadLine
Wscript.Echo strInput

Loop

Good Luck.

On Oct 16, 10:18 am, kais...@iastate.edu wrote:
> Let me preface this post by stating that I have never programmed in VB
> before. That said...
>
> I am working on a script that involves some telneting. From what I
> could find, scripting isn't available for command line inputs to
> Microsoft's telnet. So I found an alternative here:
>
> http://www.freewarefiles.com/program_10_112_3879.html
>
> It's a VB script that has its own telnet program that IS scriptable.
> It comes with a Tel.vbs file which can be edited and run as a telnet
> script. I can get everything to work great except for one feature I
> want to add. By default, this script takes the IP address from
> arguments in the shortcut properties (if you download and install this
> program, you will see this in the Tel.vbs code). I want to program the
> script to read a text file to obtain the IP address to which it will
> connect.
>
> Any suggestions?


Re: Reading from a file by kaiserd

kaiserd
Fri Oct 20 16:55:02 CDT 2006

Worked great. Thanks