Hi All
I had a look yesterday at a few threads on the forum and pulled some examples of code but cant get them to work!
I want to create a template I can use for diferent task's but first want to get it to work with something simple.
I have a text file that reads as the following;
192.168.1.1,LDNP-swa01
192.168.1.2,LDNP-swa02
192.168.1.3,LDNP-swa03
192.168.1.4,LDNP-swa04
192.168.1.5,LDNP-swa05
192.168.1.6,LDNP-swa06
192.168.1.7,LDNP-swa07
192.168.1.8,LDNP-swa08
192.168.1.9,LDNP-swa09
I want to read from the text file and add the IP-address in at a point in the script and then add the hostname in at a second point in the script. Here's the code I have been trying to get to work;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Script to change multiple hostname */
file = "c:\info.txt"
do while( lines(file) )
data=LINEIN(file)
Parse Var data v1,v2
CALL ZocTimeout 60
CALL ZocWaitForSeq 1
CALL ZocSend "ssh -l admin "
CALL ZocSend v1"^M"
CALL ZocWait "Password:"
CALL ZocSend "qwerty^M"
CALL ZocWaitForSeq 1
CALL ZocSend "conf t^M"
CALL ZocWait "4(config)#"
CALL ZocSend "hostname "
CALL ZocSend v2"^M"
CALL ZocWaitForSeq 1
CALL ZocSend "^M"
CALL ZocWaitForSeq 1
CALL ZocSend "end^M"
CALL ZocWaitForSeq 1
CALL ZocSend "wr^M"
CALL ZocWaitForSeq 2
CALL ZocSend "exit^M"
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I run the script it enters the whole line IE. "192.168.1.1,LDNP-swa01" I need to enter the IP Address at "v1" and the hostname at "v2".
I also need the script to loop untill it reaches the bottom of the text file, can this be done??
Xray
I had a look yesterday at a few threads on the forum and pulled some examples of code but cant get them to work!
I want to create a template I can use for diferent task's but first want to get it to work with something simple.
I have a text file that reads as the following;
192.168.1.1,LDNP-swa01
192.168.1.2,LDNP-swa02
192.168.1.3,LDNP-swa03
192.168.1.4,LDNP-swa04
192.168.1.5,LDNP-swa05
192.168.1.6,LDNP-swa06
192.168.1.7,LDNP-swa07
192.168.1.8,LDNP-swa08
192.168.1.9,LDNP-swa09
I want to read from the text file and add the IP-address in at a point in the script and then add the hostname in at a second point in the script. Here's the code I have been trying to get to work;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Script to change multiple hostname */
file = "c:\info.txt"
do while( lines(file) )
data=LINEIN(file)
Parse Var data v1,v2
CALL ZocTimeout 60
CALL ZocWaitForSeq 1
CALL ZocSend "ssh -l admin "
CALL ZocSend v1"^M"
CALL ZocWait "Password:"
CALL ZocSend "qwerty^M"
CALL ZocWaitForSeq 1
CALL ZocSend "conf t^M"
CALL ZocWait "4(config)#"
CALL ZocSend "hostname "
CALL ZocSend v2"^M"
CALL ZocWaitForSeq 1
CALL ZocSend "^M"
CALL ZocWaitForSeq 1
CALL ZocSend "end^M"
CALL ZocWaitForSeq 1
CALL ZocSend "wr^M"
CALL ZocWaitForSeq 2
CALL ZocSend "exit^M"
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I run the script it enters the whole line IE. "192.168.1.1,LDNP-swa01" I need to enter the IP Address at "v1" and the hostname at "v2".
I also need the script to loop untill it reaches the bottom of the text file, can this be done??
Xray