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!

How do I read line after line from a separate file?

Status
Not open for further replies.

X4Ahhzee

Technical User
Oct 23, 2003
1
US
This is probably extremely easy to do...however, I've just purchased this product & subsequently been tasked to automate password changes for a list of devices (IP Addresses).

I've worked out the actual password change function with the help of the Recorder.

Now what I need is a simplistic way of saying for each of the IP Addresses in a separate file (IP.list) telnet & do the password change function.
??

Thanks in advance,
X

PS - I'm totally under the gun on this & am frantically sifting through the docs for the first time.
 
the easiest way is to put the IP addresses in the Procomm Telnet directory.

However you can use this though it is not tested so you have to make it work but it is a general idea:

string Tempstring[Howmany]
integer i=0

if fopen 0 FileName READ
fseek 0 0 0 ; put pointer at begining of file.
;here is where I would use an aray and store all the data
;then close the file
while not feof 0
fread 0 Tempstring 255 Len ;to read in data "255"
;change to lenghth you want
i++
endwhile

fclose 0
endif

for i = 0 upto Howmany
dial TELNET tempstring
passwordsub()
endfor


To go where no programmer has gone before.
 
Here is a script that should do the trick:

proc main
string sMachine

if fopen 0 "test.txt" READ TEXT
while not feof 0
fgets 0 sMachine
if nullstr sMachine
exitwhile
endif
connectmanual TELNET sMachine
while $DIALING
yield
endwhile

disconnect
endwhile
endif
endproc

You would want to put the commands that should be sent to the system prior to the disconnect command.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top