GoneHiking
Technical User
I'm a little stumped on this one. What I have are two files of data (multiple fields, with the second field being an IP address).
In the first file (peers.txt), I want to telnet to each of the IPs in that file. Once I telnet, I want to read through another file and ping the IPs in that file. The first time around, it works fine. When I RETURN from the subroutine, the script telnet's to the second IP, but it does not call the "pingit" subroutine the second time around (or if it does, it's not reading through the file the second time).
Do I need to "reset" the file to tell it to read from line one?
This script below is just a test file. I left out a log of the logic that tells it to send the username/password, wait for a certain prompt, etc. This part is only to test and make sure it will telnet to an IP, ping a list of IPs, telnet to the next IP, and ping that same list of IPs. Hope this makes sense LOL.
Thanks,
Andy
peerfile = "c:\peers.txt"
DO WHILE (lines(peerfile) )
data=LINEIN(peerfile)
Parse Var data v1 v2 v3
testchar = RIGHT(v2,1) /* grab right-most character of field 2 */
isnum = DATATYPE(testchar) /* identify what datatype the last character is */
IF isnum = "NUM" THEN DO /* if right-most char is a number, then ping that IP */
SAY "telnet " v2 "^M"
/* ZocWait "Username:"
SAY uname
ZocWait "Password:
SAY pass
ZocWait "#" */
CALL pingit
; END
ELSE DO
NOP ; END
END
ZocSend "^M"
pingit:
pingfile = "c:\interfaces.txt"
DO WHILE ( lines(pingfile) )
data=LINEIN(pingfile)
Parse Var data v1 v2 v3
call lineout outfile, v2
letter = RIGHT(v2,1) /* grab right-most character of field 2 */
isnum = DATATYPE(letter) /* identify what datatype the last character is */
IF isnum = "NUM" THEN DO /* if right-most char is a number, then ping that IP */
SAY "ping" v2 "^M" ; END
ELSE DO
NOP ; END
END
RETURN
In the first file (peers.txt), I want to telnet to each of the IPs in that file. Once I telnet, I want to read through another file and ping the IPs in that file. The first time around, it works fine. When I RETURN from the subroutine, the script telnet's to the second IP, but it does not call the "pingit" subroutine the second time around (or if it does, it's not reading through the file the second time).
Do I need to "reset" the file to tell it to read from line one?
This script below is just a test file. I left out a log of the logic that tells it to send the username/password, wait for a certain prompt, etc. This part is only to test and make sure it will telnet to an IP, ping a list of IPs, telnet to the next IP, and ping that same list of IPs. Hope this makes sense LOL.
Thanks,
Andy
peerfile = "c:\peers.txt"
DO WHILE (lines(peerfile) )
data=LINEIN(peerfile)
Parse Var data v1 v2 v3
testchar = RIGHT(v2,1) /* grab right-most character of field 2 */
isnum = DATATYPE(testchar) /* identify what datatype the last character is */
IF isnum = "NUM" THEN DO /* if right-most char is a number, then ping that IP */
SAY "telnet " v2 "^M"
/* ZocWait "Username:"
SAY uname
ZocWait "Password:
SAY pass
ZocWait "#" */
CALL pingit
; END
ELSE DO
NOP ; END
END
ZocSend "^M"
pingit:
pingfile = "c:\interfaces.txt"
DO WHILE ( lines(pingfile) )
data=LINEIN(pingfile)
Parse Var data v1 v2 v3
call lineout outfile, v2
letter = RIGHT(v2,1) /* grab right-most character of field 2 */
isnum = DATATYPE(letter) /* identify what datatype the last character is */
IF isnum = "NUM" THEN DO /* if right-most char is a number, then ping that IP */
SAY "ping" v2 "^M" ; END
ELSE DO
NOP ; END
END
RETURN